Last active
December 10, 2019 13:36
-
-
Save jackrobertscott/f9f5b7f284ddd103ed9e9fd8dec5102a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import axios from 'axios'; | |
async function getAccessTokenFromCode(code) { | |
const { data } = await axios({ | |
url: `https://oauth2.googleapis.com/token`, | |
method: 'post', | |
data: { | |
client_id: process.env.APP_ID_GOES_HERE, | |
client_secret: process.env.APP_SECRET_GOES_HERE, | |
redirect_uri: 'https://www.example.com/authenticate/google', | |
grant_type: 'authorization_code', | |
code, | |
}, | |
}); | |
console.log(data); // { access_token, expires_in, token_type, refresh_token } | |
return data.access_token; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment