Instagram API 调用无法使用客户端 ID

Instagram API calls not working with Client ID

我正在尝试使用此处记录的 Instagram 位置搜索端点:https://www.instagram.com/developer/endpoints/locations/

我已经注册了我的应用程序并获得了客户端 ID。

当我故意省略客户端 ID 或访问令牌并提交以下内容时: https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351

我得到:

{
  "meta": {
    "error_type": "OAuthParameterException",
    "code": 400,
    "error_message": "Missing client_id or access_token URL parameter."
  }
}

这是有道理的,告诉我我应该可以使用 client_id 进行此调用(这意味着用户不必向 Instagram 进行身份验证)。

但是,当我附加 &client_id=VALID_CLIENT_ID

我得到:

{
  "meta": {
    "error_type": "OAuthAccessTokenException",
    "code": 400,
    "error_message": "The access_token provided is invalid."
  }
}

我应该能够在不进行身份验证的情况下使用此调用,我是否正确?如果是这样,对我做错了什么有什么想法吗?

谢谢!

根据 instagram OAuth 2.0 文档,您需要 access_token 才能发出经过身份验证的请求。

为了获得访问令牌,您的服务需要将用户重定向到 Instagram 以让他们登录。从这里开始,一旦用户登录,Instagram 就会将用户重定向到您选择的 url授予您使用 url 字符串中的 access_token 的访问权限。

The Instagram OAuth 2.0 docs has more details.

Also, I guess I misread the question. Here's documentation from Instagram saying that client_id is no longer supported for endpoints:

The Instagram API requires an access_token from authenticated users for each endpoint. We no longer support making requests using just the client_id.

您的请求是针对 /media/search 端点的 does require access_token (and so does /location/search,顺便说一句。)。