“(# 100) 您必须提供应用程序访问令牌或应用程序的所有者或开发者的用户访问令牌”(请参阅说明)?

问题描述 投票:0回答:6

我请求查找有关我的用户访问令牌的数据:

fetch("https://graph.facebook.com/v8.0/debug_token?input_token=" + access_token).then(function (response) {
   response.text().then(function (textII) {
       alert(textII);
   });
});

在本例中,我在向应用程序和 Facebook 授权后从 auth Response 中获取 accessToken 值:

{
    status: 'connected',
    authResponse: {
        accessToken: '{access-token}',
        expiresIn:'{unix-timestamp}',
        reauthorize_required_in:'{seconds-until-token-expires}',
        signedRequest:'{signed-parameter}',
        userID:'{user-id}'
    }
}

但是我收到错误:

{
   "error": {
      "message": "(#100) You must provide an app access token or a user access token that is an owner or developer of the app",
      "type": "OAuthException",
      "code": 100,
      "fbtrace_id": "AtpM_XaTOgH7YH-OXHdQCXj"
   }
}

我的变量 access_token 的值不为空(我检查过),而这是一种用户访问令牌(关键字“sort of”)。那么出了什么问题呢?请解释。如果您需要有关我需要它做什么的信息,那么我需要它来完成此请求:

for (var iio = 0; iio < posts_ids.length; iio++) {
fetch("https://graph.instagram.com/" + posts_ids[iio] + "?fields=id,media_type,media_url,owner,timestamp&access_token=" + access_token).then(function (response) {
      response.text().then(function (textII) {
          alert(textII);
      });
  });
}

这会引发错误:

{
   "error": {
      "message": "Invalid OAuth access token.",
      "type": "OAuthException",
      "code": 190,
      "fbtrace_id": "AD7BAPqUGdQGC6dyV9K_FFr"
   }
}

同时,在我之前的请求中,只是从“https://graph.facebook.com/”开始,而不是“https://graph.instagram.com/”,一切都与我收到的 accessToken 一起工作注册后。 请帮帮我。我是 Instagram API 的新手,所以我可能很笨。

facebook facebook-graph-api facebook-javascript-sdk instagram-api instagram-graph-api
6个回答
4
投票

请关闭设置(设置 -> 高级 -> 应用程序验证),它可以工作!


2
投票

@Denis Bredun,您还必须传递

access_token
字段作为 URL 参数,因此只需将 url 更新为 -

https://graph.facebook.com/v8.0/debug_token?input_token=<access_token>&access_token=<access_token>

1
投票

尝试重置您的应用程序机密。我遇到了同样的问题,这解决了它。


0
投票
  • 我通过将应用程序密码更改为正确的密码解决了该错误。

确保您使用正确的应用程序密钥。


0
投票

对我来说,使用 debug_token api 需要“页面令牌”和“应用程序令牌”,然后以以下格式调用 api:

https://graph.facebook.com/v<version>/debug_token?input_token=<page_token>&access_token=<app_token>

根据 facebook 文档 要获取 app_token,您需要应用程序 ID 和应用程序密钥。然后你打电话给

https://graph.facebook.com/oauth/access_token?client_id={your-app-id}&client_secret={your-app-secret}&grant_type=client_credentials

要获取 page_token,首先获取 user_token,然后将 user_token 转换为长期存在的用户令牌,然后调用 api“/?fields=access_token”获取页面令牌。 请注意,您需要对 user_token 具有适当的权限才能执行此操作,例如“pages_read_engagement”,否则您将在尝试获取页面令牌的 api 中收到错误消息。


0
投票

我通过禁用“应用程序机密是否嵌入客户端?”解决了这个问题。

© www.soinside.com 2019 - 2024. All rights reserved.