Tag: devise omniauth

如何在不使用Ruby on Rails身份validation的情况下仅将OmniAuth用于来自不同Apis的授权

我想使用OmniAuth同时从Facebook,Twitter和谷歌检索用户access_token和秘密。 我正在使用Devise进行身份validation,我想知道如何在用户登录时请求密钥并将其存储在数据库中以便以后使用。

未定义的方法`session_path’

我正在使用Rails + Devise + OmniAuth + Google OAuth2。 我的用户模型(user.rb)包含: devise :registerable, :omniauthable, :omniauth_providers => [:google_oauth2] 我的routes.rb看起来像: Rails.application.routes.draw do devise_for :users, controllers: { omniauth_callbacks: ‘omniauth_callbacks’ } devise_scope :user do get ‘sign_in’, :to => ‘devise/sessions#new’, :as => :new_user_session post ‘sign_in’, :to => ‘devise/session#create’, :as => :user_session get ‘sign_out’, :to => ‘devise/sessions#destroy’, :as => :destroy_user_session end get ‘services’, […]

Devise / Omniauth失败:如何调试?

在尝试“使用Google登录”后,我在日志中看到此错误: Processing by Users::OmniauthCallbacksController#failure as HTML 我可以通过URL(在日志中)看到谷歌发送的所有数据,包括用户电子邮件和姓名。 那怎么可能出错? 我的回调甚至没有被执行。 我只会被重定向到我网站的sign_in页面。 而且我很确定一切都配置正确,因为这在几周前工作正常。 我认为我没有改变任何东西。 Facebook登录仍然正常。 有关如何调试此故障的任何想法? 除了那些充满参数和值的长URL之外,日志中没有其他内容。 只有INFO消息。 上面发布的是唯一一个关于失败的人。 UPDATE 我向控制器添加了“故障”方法 def failure render :text => params.inspect end 哪个停止了重定向,并打印出来: {} url是这样的: /users/auth/google/callback?_method=post&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2012-04-16T12%3A25%3A49Z_v1fNngSQJaHBQ&openid.return_to=http%3A%2F%2Fdev.myapp.me%3A3000%2Fusers%2Fauth%2Fgoogle%2Fcallback%3F_method%3Dpost&openid.assoc_handle=AMlYA9Urw_lYamPphTSdQ9a6DU0Ez0y5RaDDM78qPL7Xgm77nMpJiB85&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.ext5%2Cext1.value.ext5%2Cext1.type.ext8%2Cext1.value.ext8%2Cext1.type.ext2%2Cext1.value.ext2&openid.sig=2FPjo7U1e%2Fde248XpUgjQLduNAM%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk1F5U6x_-kJnydjoww5haU41tquh1Zl2c&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawk1F5U6x_-kJnydjoww5haU41tquh1Zl2c&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.ext5=http%3A%2F%2Faxschema.org%2FnamePerson%2Ffirst&openid.ext1.value.ext5=Some_User&openid.ext1.type.ext8=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.ext8=some_email%40gmail.com&openid.ext1.type.ext2=http%3A%2F%2Faxschema.org%2FnamePerson%2Flast&openid.ext1.value.ext2=Some_User 所以我需要的所有数据都在URL中,但是devise / omniauth并没有抓住它(显然这就是为什么它调用’failure’方法而不是我的回调)。 我不知道它是否可以通过’params’数组访问,或者是什么。 我也对?_method=post部分感兴趣,因为我网站的所有请求都是GET请求。 也许这只是意味着omniauth对谷歌的请求是POST。 有什么想法吗?

使用`无法找到路径的有效映射’来设计omniauthable break Omniauth身份validation

在我的项目中,我有两种类型的用户:求职者和招聘经理。 求职者没有模特,他们只能使用从第三方提供商处收到的数据申请工作,同时通过Omniauth进行身份validation。 招聘经理的信息存储在设计用户模型中。 招聘经理还必须能够使用其公司的Google电子邮件帐户登录。 所以,首先我使用Omniauth 1.0.0,Rails 3.1.3构建了求职者的身份validation: omniauth.rb require ‘omniauth-openid’ require ‘openid/store/filesystem’ Rails.application.config.middleware.use OmniAuth::Builder do provider :openid, :store => OpenID::Store::Filesystem.new(‘./tmp’), :name => ‘google’, :identifier => ‘https://www.google.com/accounts/o8/id’ provider :facebook, “xxxxxxxxx”, “xxxxxxxxxxxxxxxxxxxxxxxxxxxx”, {:scope => ’email, offline_access, publish_stream’, :client_options => {:ssl => {:ca_file => ‘/usr/lib/ssl/certs/ca-certificates.crt’}}} provider :twitter, “xxxxxxxxxxx”, “xxxxxxxxxxxxxxxxxxxxxxxxxxx” provider :linkedin, “xxxxxxxxxxx”, “xxxxxxxxxxxxxxxxxxx” end 在routes.rb : match ‘/auth/:provider/callback’, […]