gpt4 book ai didi

ruby-on-rails - rails : Google login with omniauth

转载 作者:行者123 更新时间:2023-12-04 06:16:14 24 4
gpt4 key购买 nike

我在我的 rails 3.0.7 应用程序上使用 Devise & Omniauth,并且我已经设置了一个正常运行的 twitter 和 facebook 登录。我刚刚在 config/initializers/omniauth.rb 中使用以下几行通过 omniauth 登录 Google Apps :

require 'openid/store/filesystem'
use OmniAuth::Strategies::GoogleApps, OpenID::Store::Filesystem.new('/tmp')

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

但这会导致使用 Google Apps 登录。我如何只允许用户使用他们的标准 Google 帐户而不是 Google Apps(适用于企业)登录? Omniauth 甚至支持吗?

最佳答案

我已将其实现为 gem .如果您有兴趣,可以使用 gem 本身或探索其源代码。这很简单。

这是 the engine file它配置了设计。要在您的代码中支持标准 Google 帐户,您需要指定 :domain所指出的选项here

config.omniauth :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com'

关于ruby-on-rails - rails : Google login with omniauth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7206177/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com