使 devise、omniauth 和 google 正常工作的正确配置行是什么?
我浏览了文档,但无法弄清楚我应该使用哪一行来让 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Google 是一个 openid 实现。在您的初始文件中添加以下内容
Google is an openid implementation. Add the following in your initial file
我最终使用的行是...
结果我错过了访问 Picasa 所需的范围,这就是导致我出现问题的原因。
The line I used in the end was ...
Turns out I was missing the scope I needed to access Picasa, which was what was causing me problems.
您可能需要查看 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 :)我将以下几行添加到omniauth.rb,它的效果非常好:
I added the following lines to omniauth.rb and it worked like a charm: