【问题标题】:{"error_type": "OAuthException", "code": 400, "error_message": "Invalid redirect_uri"}{“error_type”:“OAuthException”,“code”:400,“error_message”:“无效的redirect_uri”}
【发布时间】:2020-02-25 16:20:02
【问题描述】:

首先,这是我登录后的 Instagram 网址:

https://www.instagram.com/oauth/authorize?client_id=$MYCLİENTİD&redirect_uri=https://localhost:4000/İnstagram/Insta.php/&response_type=code&scope=user_profile,user_media

这是页面显示的错误:

{"error_type": "OAuthException", "code": 400, "error_message": "Invalid redirect_uri"}

当我尝试从 Instagram 获取用户令牌时,我收到了该错误。
我试过改redirect_uri=(Valid OAuth Redirect URIs),但还是和以前一样。

【问题讨论】:

  • 可能重定向 URI 不能是 localhost
  • 之前需要对redirect_uri进行url_encode
  • 那是可能还是不是?因为我试图发送谷歌,它给出了同样的错误。 (我在 url 和 dev.facebook 的 api 设置中更改了它)并且我也制作了 url_encode
  • 我如何将 localhost redirect_uri 用于 Instagram 应用程序进行测试?它也给了我同样的错误。需要帮助

标签: php api instagram


【解决方案1】:

我无法在任何地方找到此文档,但通过反复试验,我发现 redirect_uri 必须:

  1. 使用 https
  2. 可公开访问(例如 localhost 和指定端口号不起作用)
  3. 不包括参数(我发现它们被剥离了,这会在我后来请求访问令牌时导致 redirect_uri 不匹配)

【讨论】:

  • 此外,在 Facebook 中保存 redirect_url 后,有时您必须等待长达 5 分钟
【解决方案2】:

我遇到了同样的问题,我解决了如下:
我第一次去这里: (记得在下面的 URL 中更改您的 Instagram 应用 IDhttps://developers.facebook.com/apps/your_instagram_app_id/instagram-basic-display/basic-display/

然后我将我的Client OAuth SettingsDeauthorizeData Deletion Requests 设置为“https://localhost:3000/”。

这对我有用。

【讨论】:

    【解决方案3】:

    实际上,对我来说,这是因为我的 URI 与应用程序请求的不完全相同。最后忘记加“/”了。

    【讨论】:

      【解决方案4】:

      其实用localhost也可以,但是很繁琐。

      • 首先,您需要启用 https(从您的请求中我可以看到,您似乎已经启用了)。

      • [我不知道这是否是强制性的]您需要从您的主应用程序创建一个测试应用程序* (https://developers.facebook.com/docs/development/build-and-test/test-apps/)

      • 将重定向 OAuth URI 设置为 https://localhost:4000/auth/ 之类的内容,并更新 .../instagram-basic-display/basic-display/ 设置中的所有其他 URI。

      • 最后,别忘了在你的请求中使用测试应用的client-id(或app-id),它和你的父应用不同

      祝你好运;)

      *重要提示:测试应用中的 app-id 和 app-secret 不同!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-02-17
        • 2020-05-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-02-14
        • 1970-01-01
        相关资源
        最近更新 更多