我正在使用'omniauth-google-oauth2'登录谷歌并仔细阅读此处的所有说明
https://github.com/plataformatec/devise/wiki/OmniAuth%3A-Overview
但我上面有错误。
我的路线
devise_for :users, :controllers => {
:omniauth_callbacks => "users/omniauth_callbacks"
}
devise.rb代码
config.omniauth :google_oauth2, "863625299460- 420n6c7lvad91dfvko60uamtvtr6huhf.apps.googleusercontent.com", "dcvA2aZRZi27KCQjWTYP30pw", { access_type: "offline", approval_prompt: "" }
omniauth回调控制器代码
def google_oauth2
#@user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user)
binding.pry #control not coming here
end
回调后我有错误。看截图
https://github.com/zquestz/omniauth-google-oauth2/issues/52
答案 0 :(得分:1)
这看起来像路线问题。如果你做“rake routes | grep auth”,你看到了什么?
答案 1 :(得分:0)
我遇到的问题完全相同。确保在config / initializers / deviser.rb中需要omniauth-google-oauth2 gem
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
require "omniauth-google-oauth2"
config.omniauth :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"],
{ access_type: "offline", approval_prompt: "force" }
我添加了devise.rb文件的全部内容以提供上下文。