我正在尝试使用设计和omniauth 向google oauth2 进行身份验证。我按照omniauth文档中的规定虔诚地设置了回调,甚至使用了相同的确切代码。https://github.com/plataformatec/devise/wiki/OmniAuth:-概述
我将代码上传到 github:https ://github.com/kiranjulapalli/devisetest
我被重定向到登录,当我选择我的帐户时,我再次被重定向到登录页面。我在这里想念什么?
这是日志:
Started GET "/users/auth/google_oauth2/callback?state=3baa394efe9c586b30fgfc05b1f618af04b7728d0d75c3c1&code=4/HxV9O
37jKYgxg10EWDntdfewZTz3.4kqevOMEweMTshQV0ieZDArQUdYefAI" for 127.0.0.1 at 2013-04-15 16:36:01 -0400
Processing by Users::OmniauthCallbacksController#google_oauth2 as HTML
Parameters: {"state"=>"3baa394efe9c586b30fgfc05b1f618af04b7728d0d75c3c1", "code"=>"4/HxV9O
37jKYgxg10EWDntdfewZTz3.4kqevOMEweMTshQV0ieZDArQUdYefAI"}
MOPED: 127.0.0.1:27017 COMMAND database=admin command={:ismaster=>1} (2.0001ms)
MOPED: 127.0.0.1:27017 QUERY database=devisetest_development collection=users selector={"$query"=>{"email"
=>"myemailaddress@gmail.com"}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil
(0.9999ms)
Completed 401 Unauthorized in 24ms
#custom log statements
logger::Find if this user exists
logger::Return user
logger:Got call back
logger:User persisted
我的 routes.rb 文件:
Devisetest::Application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
resources :users
root :to => 'home#index'
end