简体   繁体   English

刷新长寿命访问令牌端点是否在 2021 年工作?

[英]Is refreshing long lived access token endpoint working in 2021?

Trying to refresh my long lived access token via this endpoint:尝试通过此端点刷新我的长期访问令牌:

https://developers.facebook.com/docs/instagram-basic-display-api/guides/long-lived-access-tokens#refresh-a-long-lived-token https://developers.facebook.com/docs/instagram-basic-display-api/guides/long-lived-access-tokens#refresh-a-long-lived-token

Keep getting the error: OAuth "Facebook Platform" "invalid_token" "Invalid OAuth access token."不断收到错误: OAuth "Facebook Platform" "invalid_token" "Invalid OAuth access token."

However, I debug my token using https://developers.facebook.com/tools/debug/accesstoken/ which shows that it is valid and for around 2 months (which proves its a long lived access token).但是,我使用https://developers.facebook.com/tools/debug/accesstoken/调试我的令牌,这表明它是有效的并且大约 2 个月(这证明它是一个长寿的访问令牌)。

Does this endpoint not work anymore or am I missing something?这个端点不再工作还是我错过了什么?

PS I'm using a User Access Token, its a public Instagram business account backed by a Facebook page. PS 我使用的是用户访问令牌,它是一个由 Facebook 页面支持的公共 Instagram 商业帐户。 Also, I'm using this on server, so it won't refresh if the token is used within 60 days (that's what happens when you auth through FB mobile sdk).另外,我在服务器上使用它,因此如果令牌在 60 天内使用,它不会刷新(这就是您通过 FB 移动 sdk 进行身份验证时发生的情况)。

EDIT编辑

So it looks like there are two requirements that I missed:所以看起来我错过了两个要求:

  1. Your long lived access token has to be at least 24 hours old in order to refresh您的长期访问令牌必须至少存在 24 小时才能刷新
  2. You need the 'instagram_graph_user_profile' permission/scope when logging your user into Facebook将用户登录到 Facebook 时,您需要“instagram_graph_user_profile”权限/范围

HOWEVER然而

I tried:我试过了:

  1. Oddly enough, whenever I add that permission/scope to the list, Facebook Login always fails and says "There's something wrong".奇怪的是,每当我将该权限/范围添加到列表中时,Facebook 登录总是失败并说“有问题”。 I tried this using the facebook login react npm package , the manual login flow by just making requests, and the FB SDK login button , all the same result. I tried this using the facebook login react npm package , the manual login flow by just making requests, and the FB SDK login button , all the same result.
  2. The Facebook Graph API Explorer doesn't include this permission. Facebook Graph API Explorer 不包含此权限。 However, the list of permissions they have does include it.但是,他们拥有的权限列表确实包括它。

So what does this mean, Facebook isn't allowing refresh of long lived tokens?那么这意味着什么,Facebook 不允许刷新长寿命令牌?

NOTE : The docs on how to refresh a long lived access token are for the Basic Display API, which isn't recommended for business accounts (which is who will be using my app).注意:有关如何刷新长期访问令牌的文档适用于基本显示 API,不建议将其用于企业帐户(谁将使用我的应用程序)。 So this makes me more unsure of if it is possible to refresh tokens for the Instagram Graph API.所以这让我更加不确定是否可以刷新 Instagram Graph API 的令牌。

MORE INFO更多信息

So on the FB developer portal, if you add the Instagram Basic Display product to your app (I previously didn't have it) it allows you to ask for the instagram_graph_user_profile permission.因此,在 FB 开发者门户上,如果您将 Instagram Basic Display 产品添加到您的应用程序(我以前没有),它允许您请求instagram_graph_user_profile权限。 However, this brings up more questions:然而,这带来了更多的问题:

  1. Do I have to use Insta Graph API + Insta Basic Display in order to get aa refreshable long lived access token?我是否必须使用 Insta Graph API + Insta Basic Display 才能获得可刷新的长寿命访问令牌?
  2. If so, how does that work?如果是这样,它是如何工作的? Because Insta Basic Display is recommended for personal accounts and Graph API is for business accounts.因为 Insta Basic Display 推荐用于个人账户,Graph API 用于企业账户。
  3. If so, how do I add the instagram_graph_user_profile permission?如果是这样,我该如何添加instagram_graph_user_profile权限? It still causes FB login to fail.它仍然会导致 FB 登录失败。

So I ended up contacting a few companies that I know for a fact do what I was trying to do and they confirmed that Facebook does REQUIRE the user to re-authorize after ~60 days.所以我最终联系了几家我知道的公司做我想做的事情,他们确认 Facebook 确实要求用户在大约 60 天后重新授权。

If they don't, the long lived access token will expire.如果他们不这样做,长期访问令牌将过期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM