MCPcopy Create free account
hub / github.com/app-generator/api-server-nodejs / getGithubOathToken

Function getGithubOathToken

src/services/session.service.ts:9–34  ·  view source on GitHub ↗
({
    code,
  }: {
    code: string;
  })

Source from the content-addressed store, hash-verified

7 };
8
9 export const getGithubOathToken = async ({
10 code,
11 }: {
12 code: string;
13 }): Promise<any> => {
14 const rootUrl = 'https://github.com/login/oauth/access_token';
15 const options = {
16 client_id: process.env.GITHUB_OAUTH_CLIENT_ID,
17 client_secret: process.env.GITHUB_OAUTH_CLIENT_SECRET,
18 code,
19 };
20
21 const queryString = qs.stringify(options);
22
23 try {
24 const { data } = await axios.post(`${rootUrl}?${queryString}`, {
25 headers: {
26 'Content-Type': 'application/x-www-form-urlencoded',
27 },
28 });
29 const decoded = qs.parse(data) as GitHubOauthToken;
30 return decoded;
31 } catch (err: any) {
32 throw Error(err);
33 }
34 };
35
36 export const getGithubUser = async ({
37 access_token,

Callers 1

githubOauthHandlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected