【发布时间】:2014-03-14 21:15:19
【问题描述】:
我对 omniauth-google-oath2 gem 有疑问。
我的代码:
devise.rb
config.omniauth :google_oauth2, 'app_id','secret'
omniauth_callbacks_controller.rb
def google_oauth2
auth = env["omniauth.auth"]
@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
if @user.persisted?
flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google"
sign_in_and_redirect @user, :event => :authentication
else
session["devise.google_uid"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
我还在我的 user.rb 模型中为 find_for_google_oauth2 提供了方法。 在我的 html.erb 中,我写道:
<%= link_to "With Google", user_omniauth_authorize_path(:google_oauth2) %>
最后我有这个错误:No route matches {:controller=>"omniauth_callbacks", :action=>"passthru", :provider=>:google_oauth2, :format=>nil} missing required键:[:provider]
我的错误在哪里? 感谢您的提前!
【问题讨论】: