I am integrating Instagram login into my application. As per the provided documentation in bellow link: https://www.instagram.com/developer/authentication/
For getting CODE I hit follow API:
https://api.instagram.com/oauth/authorize?app_id="your app_id"&redirect_uri=https://www.google.com/&scope=user_profile,user_media&response_type=code
After hitting above API in web-view I got bellow new URL with code in it:
http://www.google.com/?code=AQCPw4m0jd85IX7Qi83rd-pxsFKDE8Bjb0kZ2pWZ8sarcPlNyaZXwzE1yHHqfVIgDej_ZPYrTh6_BaIafsOWsTZNJbWFDiXsQPTEZHvFBojQ5F91SBSykqjUkG0U1OS6nFyAcwNq-FsbpmBtIPcp45qNXV5_avgCCpBzG-Hndp6JiRbaF2uSgUiOep5-Uu0Ks8DiwVs_7zAfuMasJJ7PAK1gfRDNVOPC-XBYqfdPU1VlkA
In this example my code is
AQCPw4m0jd85IX7Qi83rd-pxsFKDE8Bjb0kZ2pWZ8sarcPlNyaZXwzE1yHHqfVIgDej_ZPYrTh6_BaIafsOWsTZNJbWFDiXsQPTEZHvFBojQ5F91SBSykqjUkG0U1OS6nFyAcwNq-FsbpmBtIPcp45qNXV5_avgCCpBzG-Hndp6JiRbaF2uSgUiOep5-Uu0Ks8DiwVs_7zAfuMasJJ7PAK1gfRDNVOPC-XBYqfdPU1VlkA
I use it in access_token request below:
https://api.instagram.com/oauth/access_token?
app_id="YOUR APP ID"
&app_secret="YOUR SECRET KEY"
&grant_type=authorization_code
&redirect_uri=https%3A%2F%2Fwww.google.com%2F
&code=AQCPw4m0jd85IX7Qi83rd-pxsFKDE8Bjb0kZ2pWZ8sarcPlNyaZXwzE1yHHqfVIgDej_ZPYrTh6_BaIafsOWsTZNJbWFDiXsQPTEZHvFBojQ5F91SBSykqjUkG0U1OS6nFyAcwNq-FsbpmBtIPcp45qNXV5_avgCCpBzG-Hndp6JiRbaF2uSgUiOep5-Uu0Ks8DiwVs_7zAfuMasJJ7PAK1gfRDNVOPC-XBYqfdPU1VlkA
Response of above api hit:
{
"access_token": "IGQVJVT2hod1dEN3N0UnBwTWllb3pZAaENnS0VveHZARSkNwLVpwS2Uxc0w2VUVOeEJxaUdkMnlQRkdzVGJudnh0cXREZA3BvWHNELTR1UndsOWR2MXFST0JlUG45TEdFVnhiblhScVNlYlJtLUNwQU5Kc2ltZAy1LUlRMaF9ZA",
"user_id": 17841406439718884
}
Now in order to get User Profile data, I am hitting bellow api using above access_token as mentioned in [link][1] :
Api hit :
https://api.instagram.com/v1/users/self/?access_token="+accesstoken
But in this api, I am getting error which says:
{
"meta": {
"code": 400,
"error_type": "OAuthAccessTokenException",
"error_message": "The access_token provided is invalid."
}
}
Please let me know how to get valid accessToken programmatically , I have clearly mentioned every step I follow if you stil need anything for more calrification I willprovide you that too!!!
I have followed each and every step mentioed in this link :
https://developers.facebook.com/docs/instagram-basic-display-api/guides/getting-access-tokens-and-permissions