错误:使用omniauth-google-oauth2时redirect_uri_mismatch
问题描述:
我使用Facebook登录工作。我现在正尝试登录Google工作。错误:使用omniauth-google-oauth2时redirect_uri_mismatch
我得到错误:redirect_uri_mismatch,我找不出原因。
我看到有人说在哪里使用omniauth-oauth2诉1.3.1,所以我是。
我的路线文件包括:
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2', '~> 0.4.1'
gem 'omniauth-oauth2', '~> 1.3.1'
我omniauth.rb文件是:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['FACEBOOK_APP_ID'], ENV['FACEBOOK_SECRET'], info_fields: 'email,first_name,last_name'
provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"],
{
:name => "google",
:scope => "email, profile, plus.me, http://gdata.youtube.com",
:prompt => "select_account",
:image_aspect_ratio => "square",
:image_size => 50
}
end
我已经采取了错误信息
The redirect URI in the request, http://localhost:3000/auth/google/callback, does not match the ones authorized for the OAuth client
和复制的URI,然后进入google api的信用卡页面,然后添加确切的uri作为授权重定向URI。
任何帮助将不胜感激。
答
在console.developers.google.com。输入您的应用的网址加上
“/auth/google_oauth2/callback”
in“Authorized redirect URIs field。所以它应该是:
http://localhost:3000/auth/google_oauth2/callback
当我这样做,我得到:没有路由匹配[GET] “/认证/ google_oauth2” – atarihomestar
我的routes.rb包括:获得 '/ auth /中:供应商/回调',以:'sessions#create_omniauth' – atarihomestar
从终端上,我可以运行“curl localhost:3000/auth/google_oauth2/callback”,并找到该路线。但是如果我在没有/回调的情况下尝试它,它不会。这几乎就像谷歌不回发/回调。 – atarihomestar