【发布时间】:2015-12-11 23:32:13
【问题描述】:
重现步骤
- 在客户端注册一个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_serverclient_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 和访问令牌。
实际行为
端点响应:
code=400
error_type = 'OAuthException'
error_message = 'Redirect URI doesn't match original redirect URI'
到目前为止我调查的内容
为了确认这是 Instagram 的问题,我检查了the API docs,它非常清楚地表明应该可以将查询参数添加到重定向 URI。我还尝试仅更改该查询参数。例如,当用这个 /oauth/authorize URL 替换时,我得到了预期的行为:
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 的错误,但我想看看是否有人发现了这个错误或想出了解决方法。
【问题讨论】:
-
您在验证令牌时是否提供完全相同的重定向 URL?我很快就会需要这个功能 - 会更新
-
我确实尝试添加查询,它确实对我有用,也许 instagram 现在支持它。确保编码回调 url。
-
@HosseinAmin 感谢您的提示。没有考虑对回调 url 进行编码。你拯救了我的一天。
标签: oauth instagram instagram-api