MCPcopy Create free account
hub / github.com/Kong/insomnia / fetchUser

Method fetchUser

packages/insomnia/src/sync/git/providers/github.ts:214–235  ·  view source on GitHub ↗

* Fetch user info from GitHub * Used during OAuth completion to get user details

(token: string)

Source from the content-addressed store, hash-verified

212 * Used during OAuth completion to get user details
213 */
214 async fetchUser(token: string): Promise<ProviderUser> {
215 const response = await net.fetch(`${this.config.apiUrl}/user`, {
216 headers: {
217 Authorization: `token ${token}`,
218 Accept: 'application/vnd.github.v3+json',
219 },
220 });
221
222 if (!response.ok) {
223 throw new Error(`GitHub API error: ${response.statusText}`);
224 }
225
226 const data = (await response.json()) as GitHubUserApiResponse;
227
228 return {
229 id: String(data.id),
230 username: data.login,
231 name: data.name || data.login,
232 email: data.email || undefined,
233 avatarUrl: data.avatar_url,
234 };
235 }
236
237 /**
238 * Fetch user emails from GitHub with token

Callers 1

completeOAuthMethod · 0.95

Calls 2

fetchMethod · 0.80
jsonMethod · 0.80

Tested by

no test coverage detected