简体   繁体   English

Rails 设计+omniauth-google-oauth2

[英]Rails devise+omniauth-google-oauth2

I am trying to implement login from google in my rails app.I am following instructions from README file at github page of the "omniauth-google-oauth2" LINK .I am trying to use the name parameter in devise.rb config file so that links are from "google" and not "google_oauth2".我正在尝试在我的 Rails 应用程序中实现从谷歌登录。我正在按照“omniauth-google-oauth2”链接的 github 页面上的 README 文件中的说明进行操作。我正在尝试在 devise.rb 配置文件中使用 name 参数,以便链接来自“google”而不是“google_oauth2”。
So i have added:所以我补充说:

config.omniauth :google_oauth2, "GOOGLE_CLIENT_ID", "GOOGLE_CLIENT_SECRET", { name: "google" }

But in the bottom links of devise views the link is still 但是在设计视图的底部链接中,链接仍然是
http://localhost:3000/users/auth/google_oauth2 http://localhost:3000/users/auth/google_oauth2
but clicking on this link gives 但是单击此链接会给出
Not found.未找到。 Authentication passthru.身份验证通道。
on page. 在页面上。
But now 但现在
http://localhost:3000/users/auth/google http://localhost:3000/users/auth/google
works.How do i fix the link? 工作。我如何修复链接?

config.omniauth :google_oauth2, 
                "GOOGLE_CLIENT_ID", 
                "GOOGLE_CLIENT_SECRET", 
                { name: "google" }

Works just fine to change the provider name.可以很好地更改提供程序名称。 2 caveats 2 警告

  1. Change it everywhere!到处换! Make sure your callback is using google , make sure your callback URL (in the google developer console) uses google确保您的回调使用google ,确保您的回调 URL(在 google 开发者控制台中)使用google
  2. Restart your server - because it's in an initializer, any changes you've made won't be activated until you restart重新启动您的服务器 - 因为它在初始化程序中,所以您所做的任何更改都不会在您重新启动之前被激活

Test App: https://github.com/trh/devise_omniauth_google测试应用: https ://github.com/trh/devise_omniauth_google

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM