({
code,
}: {
code: string;
})
| 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, |
no outgoing calls
no test coverage detected