Oauth2 Instagram API"重定向URI与注册的重定向URI不匹配"

Bik*_*ire 16 ruby-on-rails oauth-2.0 omniauth instagram

我正在开发一个处于开发模式的Rails应用程序,它可以注册omniauth.

主持人是

http://localhost:3000/
Run Code Online (Sandbox Code Playgroud)

我正在使用宝石:

gem 'omniauth'
gem 'omniauth-foursquare'
gem 'omniauth-instagram'
Run Code Online (Sandbox Code Playgroud)

当我通过Foursquare注册omniauth时,根本没有问题.所有设置都是正确的,我在Foursquare开发人员设置中的redirect_uri等于主机(localhost:3000)

但是,如果我在Instagram客户端管理器*中填写完全相同的redirect_uri(localhost:3000).Instagram给了我这个:

{
 "code": 400,
 "error_type": "OAuthException",
 "error_message": "Redirect URI does not match registered             redirect URI"
}
Run Code Online (Sandbox Code Playgroud)

基于此URL:

https://instagram.com/oauth/authorize?response_type=code&client_id=<ID>&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Finstagram%2Fcallback&state=18415adf24dd97873e61094f67c0fb7a94857fedf93e9d2e&scope=basic
Run Code Online (Sandbox Code Playgroud)

* 在此输入图像描述

根据Instagram,我做错了什么,应该如何解决?

Bik*_*ire 25

自己解决了这个问题.添加localhost:3000/auth/instagram/callback为redirect_uri,它工作得很好.


小智 8

我需要补充一下

http://localhost:3000/users/auth/instagram/callback
Run Code Online (Sandbox Code Playgroud)

作为我的回调URI,因为我正在使用Devise.


小智 6

当您指定重定向URI时,http:// localhost:3000http:// localhost:3000 /是不同的(请注意结尾的斜杠)。

确保回调URI完全匹配。