oauth - 向 Instagram auth redirect_uri 添加查询参数不起作用?

标签 oauth instagram instagram-api

重现步骤

  • 在客户端注册一个redirect_uri:http://example.com/publisher/auth
  • 使用包含查询参数的 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
    
  • 对 Instagram 用户进行身份验证并允许该应用程序。
  • 用户被重定向回正确的redirect_uri。
  • 使用重定向 URI 中的代码查询参数发布到 Instagram 的/oauth/access_token 端点。

  • 预期行为

    端点以 200 和访问 token 响应。

    实际行为

    端点响应:
    
    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

    笔记

    这个问题实际上是 another question 的重复这实际上并没有真正成为一个问题,而且从来没有得到任何答案。

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

    最佳答案

    今天有同样的问题。要获取在请求之间传递的自定义数据,您必须将其包含为 state参数。我的授权请求网址如下所示:

    https://www.instagram.com/oauth/authorize?client_id=SOME_CLIENT_ID&response_type=code&redirect_uri=http://example.com/auth/InstagramRedirect/&state=855C0114-F860-420A-AEB1-A276644FCCEA



    请注意 & 状态 =...

    关于oauth - 向 Instagram auth redirect_uri 添加查询参数不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32590652/

    相关文章:

    android - 获取 Instagram 快拍 Json

    facebook - 通过跨域 php 通过多个域连接使用 facebook 进行身份验证?

    facebook - 存储用户的 Facebook 访问 token

    iOS:身份验证数据错误,来自 Twitter 的代码 215

    swift - 当用户喜欢您的帖子(如 Instagram)时发送推送通知

    android - 显示 Instagram 缩略图的全屏图像

    android - 经过验证的 cordova 应用程序可以验证应用程序内的 Web View 吗?

    node.js - 查看我自己的 Instagram 照片?

    instagram - 无法获得 Instagram Basic Display API 的 access_token

    python - 日期之间的 Instagram graph api 媒体帖子