将查询参数添加到 Instagram 身份验证redirect_uri不起作用?



复制

的步骤
  1. 在客户端注册一个redirect_uri: http://example.com/publisher/auth
  2. 使用包含查询参数的redirect_uri将用户定向到/oauth/authorize端点:
    https://api.instagram.com/oauth/authorize/?client_id=xxx&redirect_uri=http%3A%2F%2Fexample.com%2Fpublisher%2Fauth%3FinviteId%3D00001000-cf33-11e4-9f26-8789dd0b3e01&response_type=code&scope=basic&type=web_server
    作为参考,这些查询参数为:
    client_id=xxx
    redirect_uri=http%3A%2F%2Fexample.com%2Fpublisher%2Fauth%3FinviteId%3D00001000-cf33-11e4-9f26-8789dd0b3e01
    response_type=code
    scope=basic
    type=web_server
    
  3. 验证instagram用户并允许应用程序。
  4. 用户被重定向回正确的redirect_uri。
  5. 使用重定向URI中的代码查询参数发布到Instagram的/oauth/access_token端点。
<标题> 预期行为

端点响应200和一个访问令牌。

<标题> 实际行为

端点响应:


code=400
error_type = 'OAuthException'
error_message = 'Redirect URI doesn't match original redirect URI'

What I've Investigated So Far

To confirm that this is a problem with Instagram, I checked the API docs which very clearly state that adding query parameters to the redirect URI should be possible. I also tried varying only that query parameter. For example, when replaced with this /oauth/authorize URL I get the expected behavior:

https://api.instagram.com/oauth/authorize/?type=web_server&client_id=xxx&redirect_uri=http%3A%2F%2Fexample.com%2Fpublisher%2Fauth&response_type=code&scope=basic

作为参考,这些查询参数如下:

client_id=xxx
redirect_uri=http%3A%2F%2Fexample.com%2Fpublisher%2Fauth
response_type=code
scope=basic
type=web_server
<标题> 指出

这个问题实际上是另一个问题的重复,而另一个问题实际上并不是一个问题,也没有得到任何答案。

我已经提交了一个Instagram的bug,但我想看看是否有人发现了这个问题或提出了一个解决方案。

今天遇到了同样的问题。要获得在请求之间传递的自定义数据,必须将其作为state参数包含。我的授权请求url看起来像这样:

https://www.instagram.com/oauth/authorize?client_id=SOME_CLIENT_ID& response_type = code& redirect_uri = http://example.com/auth/InstagramRedirect/,状态= 855 c0114 f860 - 420 a - aeb1 a276644fccea

注意到国家 =…

您必须为redirect_uri提供额外的搜索参数作为最后一个参数:

https://www.instagram.com/oauth/authorize/?client_id=be1b911b487f4919b9c2fb7df0c4142c& type = web_server&response_type = code&范围= basic& redirect_uri = https://wpwifidemo.alepo.net/instagram/joinus/?inviteid=00001000 cf33 - 11 - e4 - 9 - f26 - 8789 dd0b3e01

用户将被重定向到:

https://wpwifidemo.alepo.net/instagram/joinus/?inviteid=00001000 cf33 - 11 - e4 - 9 - f26 - 8789 dd0b3e01&代码=

现在回答这个问题可能太晚了。但今天我又遇到了同样的问题。得到这个问题已经张贴和解决方案的参数传递到认证URL如下。

似乎你的额外参数是类型=web_server,考虑到这一点,你的URL获取代码应该如下

https://www.instagram.com/oauth/authorize/?client_id=be1b911b487f4919b9c2fb7df0c4142c& redirect_uri = https://wpwifidemo.alepo.net/instagram/joinus/? type = web_server , response_type = code&范围=基本

然后在调用accessToken API时,用您传递的参数附加您的redirect_uri参数(与应用程序中配置的不一样)。例如

3

redirect_uri = http % % 2 f % 2 fexample.com % 2 fpublisher % 2 fauth % 3 finviteid % 3 d00001000 - cf33 - 11 - e4 - 9 - f26 - 8789 dd0b3e01 ? type = web_server

最新更新