【发布时间】:2016-08-01 00:22:01
【问题描述】:
我已使用 Facebook 登录。我现在正在尝试使用 Google 登录。
我得到错误:redirect_uri_mismatch,我不知道为什么。
我看到有人说要使用omniauth-oauth2 v. 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。
任何帮助将不胜感激。
【问题讨论】:
-
试试这个答案,它对我有用stackoverflow.com/a/41466634/1770571
标签: ruby-on-rails oauth