Skip to content

Instantly share code, notes, and snippets.

@jackrobertscott
Last active December 10, 2019 11:23
Show Gist options
  • Save jackrobertscott/6496246156ebebfcf83a66e49d6be410 to your computer and use it in GitHub Desktop.
Save jackrobertscott/6496246156ebebfcf83a66e49d6be410 to your computer and use it in GitHub Desktop.
import axios from 'axios';
async function getAccessTokenFromCode(code) {
const { data } = await axios({
url: 'https://graph.facebook.com/v4.0/oauth/access_token',
method: 'get',
params: {
client_id: process.env.APP_ID_GOES_HERE,
client_secret: process.env.APP_SECRET_GOES_HERE,
redirect_uri: 'https://www.example.com/authenticate/facebook/',
code,
},
});
console.log(data); // { access_token, token_type, expires_in }
return data.access_token;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment