我想在我的 Rails 应用程序上使用 Google 添加omniauth,但重定向后出现错误
ERROR -- omniauth: (google_oauth2) Authentication failure! invalid_credentials: OAuth2::Error, redirect_uri_mismatch: Bad Request
{
"error": "redirect_uri_mismatch",
"error_description": "Bad Request"
}
我看到了有关错误重定向 uri 的错误,但没有看到“错误请求”
我在谷歌控制台中的重定向 uri
http://localhost:3000/clients/auth/google_oauth2/callback
我的路线
devise_for :clients, controllers: { omniauth_callbacks: 'clients/omniauth_callbacks' }
宝石文件
gem 'omniauth-oauth2'
gem 'omniauth-google-oauth2'
gem "omniauth-linkedin-oauth2"
gem 'omniauth-rails_csrf_protection', '~> 1.0'
设计
config.omniauth :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], access_type: "online"
我的链接
<%= link_to "Sign in with Google", client_google_oauth2_omniauth_authorize_path, method: :post %>