OAuthAccessTokenException-The access_token provided is invalid Instagram new api

前端 未结 1 1316
野的像风
野的像风 2020-12-04 03:20

I am integrating Instagram login into my application. As per the provided documentation in bellow link: https://www.instagram.com/developer/authentication/

For gett

相关标签:
1条回答
  • 2020-12-04 03:38

    It is very poorly documented by Facebook and they made it very difficult. I will go through the steps so that you do not suffer as much I suffered...

    {
        "access_token": "IGQVJVT2hod1dEN3N0UnBwTWllb3pZAaENnS0VveHZARSkNwLVpwS2Uxc0w2VUVOeEJxaUdkMnlQRkdzVGJudnh0cXREZA3BvWHNELTR1UndsOWR2MXFST0JlUG45TEdFVnhiblhScVNlYlJtLUNwQU5Kc2ltZAy1LUlRMaF9ZA",
        "user_id": 17841406439718884
    }

    This is a short-lived token which expires in 1 hour; therefore you should use that to generate a long-lived token. before it expires: To do so used that piece link in postman

     "https://graph.instagram.com/access_token
      ?grant_type=ig_exchange_token
      &client_secret={instagram-app-secret}
      &access_token={short-lived-access-token}"

    Then you will get as a response

    {
      "access_token":"{long-lived-user-access-token}",
      "token_type": "bearer",
      "expires_in": 5183944  // Number of seconds until token expires
    }

    This is your long term access token and it shows the expiration date which 60 days. Then you should use the request lin

    GET https://graph.instagram.com/{media-id}
      ?fields=id,caption,username,
      &access_token={access-token}// Long Lived token

    See their website for more data query: https://developers.facebook.com/docs/instagram-basic-display-api/reference/user#fields

    I hope that helps you to solve the problem. I am writing a piece code to refresh the long-lived token before its expiration in 60 days. Once I finish it I will share that as well

    0 讨论(0)
提交回复
热议问题