Instagram access token expiry time

烂漫一生 提交于 2019-12-11 14:33:15

问题


I am using Instagram token for login.

After login, I am getting token also, but that token is not permanent. It will expire after some times. What should we do after token is expired; or how can we know that token will got expired?


回答1:


Use the Access Token Debugger found here: https://developers.facebook.com/tools/debug/accesstoken/

Enter your User Access Token and click "Debug". At the bottom, there is a button labeled "Extend Access Token". That will convert your short-lived token to a long-lived token. I'm still trying to figure out how to do this programmatically. If anyone knows, please let me know. I'm using ColdFusion 9 (yeah I know I'm way behind).




回答2:


According to the documentation about Instagram authentication

Access tokens may expire at any time in the future

But in the same page, the doc points out (emphasis mine) :

Even though our access tokens do not specify an expiration time, your app should handle the case that either the user revokes access, or Instagram expires the token after some period of time. If the token is no longer valid, API responses will contain an “error_type=OAuthAccessTokenException”. In this case you will need to re-authenticate the user to obtain a new valid token.

In other terms, your app doesn't need to fetch a new token for every request, it just needs to spot API responses with error_type=OAuthAccessTokenException in it and requests a new token when it happens.

Instagram doesn't seem to provide usual mecanism of refresh token where another token with a much further expiration date allow to request a new access token without the login step again.



来源:https://stackoverflow.com/questions/52044379/instagram-access-token-expiry-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!