MCPcopy Index your code
hub / github.com/coder/mux / fetchGithubLogin

Method fetchGithubLogin

src/node/services/serverAuthService.ts:760–786  ·  view source on GitHub ↗
(accessToken: string)

Source from the content-addressed store, hash-verified

758 }
759
760 private async fetchGithubLogin(accessToken: string): Promise<Result<string, string>> {
761 const response = await fetch(GITHUB_USER_API_URL, {
762 method: "GET",
763 headers: {
764 Accept: "application/vnd.github+json",
765 Authorization: `Bearer ${accessToken}`,
766 "User-Agent": "mux-server-auth",
767 },
768 });
769
770 if (!response.ok) {
771 const errorBody = await response.text().catch(() => "");
772 return Err(
773 `Failed to fetch GitHub user profile (${response.status})${
774 errorBody ? `: ${errorBody}` : ""
775 }`
776 );
777 }
778
779 const json = (await response.json()) as unknown;
780 const payload = parseGithubUserResponse(json);
781 if (!payload.login) {
782 return Err("GitHub user profile did not include a login name");
783 }
784
785 return Ok(payload.login);
786 }
787
788 private async createSessionLocked(opts?: {
789 userAgent?: string;

Callers 1

pollGithubDeviceFlowMethod · 0.95

Calls 4

ErrFunction · 0.90
OkFunction · 0.90
parseGithubUserResponseFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected