如何检查/调试Instagram基本显示API令牌

发布于 2025-01-20 01:43:28 字数 982 浏览 3 评论 0原文

与Instagram Basic Display链接时,我们的应用要求user_profileuser_media scopes。链接时,用户可以删除user_media范围,该范围违反了与我们的应用链接的目的。

我想验证用户已授予user_media权限,但无法找到一种很好的方法。

facebook access access访问deken debugger 能够显示我粘贴范围的范围在IG基本令牌中。

我已经尝试使用/debug_token 来自图形API。它让我可以调试Facebook和IG图形令牌,但不是IG Basic:

GET /debug_token?input_token=<token-to-debug>&access_token=<app-access-token>

我提供的“ App-Access-token”是我的Instagram Basic Display应用程序的ID和秘密这样的组合:app-ID | app--秘密

当我这样做时,我会发现一个错误:

错误验证应用程序。由于系统错误,无法获取应用程序信息。

我唯一能想到的是尝试访问用户的IG媒体,并检测是否失败了,如果没有权限错误。如果有更好的方法,我想避免这样做:)

When linking with the Instagram Basic Display, our app asks for the user_profile and user_media scopes. When linking, the user can de-select the user_media scope, which defeats the purpose of linking with our app.

I'd like to validate that the user has granted the user_media permissions, but can't figure out a good way to do it.

The Facebook Access Token Debugger is able to display the scopes that were granted when I paste in an IG Basic token.

I've tried using the /debug_token endpoint from the Graph API. It lets me debug Facebook and IG Graph tokens, but not IG Basic:

GET /debug_token?input_token=<token-to-debug>&access_token=<app-access-token>

The "app-access-token" I'm supplying is my Instagram Basic Display app's ID and secret combined together like this: app-id|app-secret

When I do this I get an error saying:

Error validating application. Cannot get application info due to a system error.

The only thing I can think of doing is to try accessing the user's IG media and detecting if it fails w/a permissions error. I'd like to avoid doing this if there is a better way :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼波传意 2025-01-27 01:43:28

我最终使用一个 api 请求来验证这一点,该请求尝试获取用户发布的最后一个媒体:

(Ruby)

  def validate_permissions
    params = { access_token: token, fields: ['id'], limit: 1 }
    get('https://graph.instagram.com/me/media', params)
  end

此类中的 get 方法有一个错误处理程序,用于处理 HTTP 状态 >= 400 的情况在错误处理程序中,如果 HTTP 状态为 403 并且错误的“代码”为 190,那么我们可以断定用户尚未授予权限。

这种情况下的错误消息是:

应用程序没有执行此操作的权限(访问用户媒体)

I ended up verifying this with an api request that tries to fetch the last media posted by the user:

(Ruby)

  def validate_permissions
    params = { access_token: token, fields: ['id'], limit: 1 }
    get('https://graph.instagram.com/me/media', params)
  end

The get method in this class has an error handler for when the HTTP status >= 400. In the error handler, if the HTTP status is a 403 and the error has a "code" of 190 then we can conclude the user has not granted the permission.

The error message in this scenario is:

Application does not have permission for this action (access user media)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文