问题
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