This repository has been archived by the owner on Sep 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from ovsoinc/plus
Plus
- Loading branch information
Showing
3 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const axios = require('axios'); | ||
|
||
module.exports = { | ||
async getAccessToken(code) { | ||
const {data:{access_token}} = await axios.post('https://github.com/login/oauth/access_token', { | ||
client_id: process.env.CLIENT_ID, | ||
client_secret: process.env.CLIENT_SECRET, | ||
code | ||
}, { | ||
headers: { | ||
Accept: 'application/json' | ||
} | ||
}); | ||
|
||
return access_token; | ||
}, | ||
|
||
async getUser(accessToken) { | ||
const {data} = await axios.get('https://api.github.com/user', { | ||
headers: { | ||
Authorization: `token ${accessToken}` | ||
} | ||
}); | ||
|
||
return data; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters