使 devise、omniauth 和 google 正常工作的正确配置行是什么?

发布于 2024-10-18 05:25:36 字数 535 浏览 2 评论 0原文

我浏览了文档,但无法弄清楚我应该使用哪一行来让 devise +omniauth+google 很好地协同工作。

该策略文件表明有一种简单的方法可以做到这一点,但我找不到示例。

https://github.com/intridea /omniauth/blob/master/oa-oauth/lib/omniauth/strategies/google.rb

目前,我正在 devise.rb 初始化程序文件中使用以下行。

config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET_KEY

但我很确定它是不完整的。

另外,我正在努力寻找应该在哪里注册 google 应用程序 ID 和密钥。

提前致谢。 格雷姆

I've looked through the documentation and I can't figure out the specific line I'm meant to use to get devise + omniauth + google working together nicely.

This strategy file suggests there's an easy way of doing it but I can't find an example.

https://github.com/intridea/omniauth/blob/master/oa-oauth/lib/omniauth/strategies/google.rb

At the moment I'm using the line below in the devise.rb initializer file.

config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET_KEY

but I'm pretty sure it's incomplete.

Also, I'm struggling to find where I should sign up for the google app id and secret key.

Thanks in advance.
Graeme

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

仅此而已 2024-10-25 05:25:36

Google 是一个 openid 实现。在您的初始文件中添加以下内容

provider :openid, OpenID::Store::Filesystem.new('./tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'

Google is an openid implementation. Add the following in your initial file

provider :openid, OpenID::Store::Filesystem.new('./tmp'), :name => 'google', :identifier => 'https://www.google.com/accounts/o8/id'
左岸枫 2024-10-25 05:25:36

我最终使用的行是...

config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET, :scope => "http://www.google.com/m8/feeds http://picasaweb.google.com/data/"

结果我错过了访问 Picasa 所需的范围,这就是导致我出现问题的原因。

The line I used in the end was ...

config.omniauth :google, GOOGLE_APP_ID, GOOGLE_SECRET, :scope => "http://www.google.com/m8/feeds http://picasaweb.google.com/data/"

Turns out I was missing the scope I needed to access Picasa, which was what was causing me problems.

倒带 2024-10-25 05:25:36

您可能需要查看 https://github.com/holden/devise-omniauth-example。特别是,请查看 user.h 中定义的 方法。 rb,他们使用的 user_token 模型,设计视图devise.rb 。最后一个特别展示了如何配置 devise/omniauth 以通过 openid 与 google 一起使用: config.omniauth :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com' 希望有帮助:)

You may want to look at https://github.com/holden/devise-omniauth-example. In particular, look at the methods defined in user.rb, the user_token model they use, the devise views, and devise.rb. The last one in particular shows how you can configure devise/omniauth to work with google via openid: config.omniauth :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com' Hope it helps :)

陪你搞怪i 2024-10-25 05:25:36

我将以下几行添加到omniauth.rb,它的效果非常好:

Rails.application.config.middleware.use OmniAuth::Builder do  
   provider :openid, nil, :name => 'google', :identifier =>'https://www.google.com/accounts/o8/id'  
end

I added the following lines to omniauth.rb and it worked like a charm:

Rails.application.config.middleware.use OmniAuth::Builder do  
   provider :openid, nil, :name => 'google', :identifier =>'https://www.google.com/accounts/o8/id'  
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文