Skip to content

Instantly share code, notes, and snippets.

@bibhuticoder
Last active July 29, 2021 10:00
Show Gist options
  • Save bibhuticoder/7434a786440069e6e95685a08b7f9858 to your computer and use it in GitHub Desktop.
Save bibhuticoder/7434a786440069e6e95685a08b7f9858 to your computer and use it in GitHub Desktop.
// data from frontend
let code = req.body.code;
let redirectUri = req.body.redirectUri;
let accessToken = null;
try {
// send form based request to Instagram API
let result = await request.post({
url: 'https://api.instagram.com/oauth/access_token',
form: {
client_id: process.env.INSTA_APP_ID,
client_secret: process.env.INSTA_APP_SECRET,
grant_type: 'authorization_code',
redirect_uri: req.body.redirectUri,
code: req.body.code
}
});
// Got access token. Parse string response to JSON
accessToken = JSON.parse(result).access_token;
} catch (e) {
console.log("Error=====", e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment