Last active
July 29, 2021 10:00
-
-
Save bibhuticoder/7434a786440069e6e95685a08b7f9858 to your computer and use it in GitHub Desktop.
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
// 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