问题
Facebook sent me an alert yesterday:
"As part of ongoing changes to improve overall privacy of our Platform we recently made changes to our Platform Terms and Developer Policies. We are also making a change with respect to access token refresh for apps using the Instagram Basic Display API.
As of August 31, 2020, developers using the Instagram Basic Display API will no longer have continued access to private Instagram account information without reauthorization from the account. Apps calling the GET /refresh_access_token API endpoint will not receive a refreshed access token when they call the endpoint for private Instagram accounts.
This change will require private Instagram accounts to re-authorize at least every 60 days in order for developers to maintain continued access to their current data using the Instagram Basic Display API. This change will only apply to private Instagram accounts; access to data for public Instagram accounts using this API endpoint will remain unchanged."
So in my understanding, for private account, if its access token is expired, I cannot use the API GET /refresh_access_token
to refresh the token anymore but I have to re-authorize the token from scratch.
In this case, how can I check if user's Instagram account is public or private? I did not find anything related to this on Instagram Basic Display API doc; or perhaps I missed something...
I would be truly grateful if someone can shed a light for me on this matter.
回答1:
Since I had no idea how to identify if an account is public or private, I just applied the API GET /refresh_access_token
to them all. It works fine for public accounts, but for private ones, it will return an error object:
{
"error": {
"message": "Application does not have permission for this action",
"type": "OAuthException",
"code": 10,
"error_subcode": 2207054,
"is_transient": false,
"error_user_title": "Permission Denied",
"error_user_msg": "You cannot refresh access tokens for Instagram private accounts. To generate a new access token, reauthorize the user as documented here https://developers.facebook.com/docs/instagram-basic-display-api/guides/getting-access-tokens-and-permissions\"",
"fbtrace_id": "#####"
}
}
So once private account is identified, it is easy to apply re-authorization to it.
来源:https://stackoverflow.com/questions/63644024/instagram-basic-display-api-how-to-check-if-users-instagram-account-is-public