Redirect Rails中的LinkedIn Omniauth OAuth 2-错误重定向的身份验证失败

Redirect Rails中的LinkedIn Omniauth OAuth 2-错误重定向的身份验证失败,redirect,ruby-on-rails-4,devise,omniauth,linkedin-gem,Redirect,Ruby On Rails 4,Devise,Omniauth,Linkedin Gem,我正试图弄清楚如何用我的Rails 4应用程序配置LinkedIn的身份验证,该应用程序使用Desive和omniauth。我的gem文件中有:gem'omniauth-linkedin-oauth2' 我已经在LinkedIn注册了我的应用程序,并在我的应用程序中插入了密码和密钥。LinkedIn开发者论坛已确认该过程正在运行,但表示注册的重定向路径与回调中的路径不匹配 我有一个omniauth_回调控制器,其中包含以下代码: def linkedin @user = User.fin

我正试图弄清楚如何用我的Rails 4应用程序配置LinkedIn的身份验证,该应用程序使用Desive和omniauth。我的gem文件中有:gem'omniauth-linkedin-oauth2'

我已经在LinkedIn注册了我的应用程序,并在我的应用程序中插入了密码和密钥。LinkedIn开发者论坛已确认该过程正在运行,但表示注册的重定向路径与回调中的路径不匹配

我有一个omniauth_回调控制器,其中包含以下代码:

def linkedin
    @user = User.find_for_linkedin_oauth(request.env["omniauth.auth"])
      if @user.persisted?
        redirect_to root_path, :event => :authentication
        # sign_in_and_redirect @user, :event => :authentication #this will throw if @user is not activated
        #  set_flash_message(:notice, :success, :kind => "LinkedIn") if is_navigational_format?
        else
          session["devise.linkedin_data"] = request.env["omniauth.auth"]
          redirect_to root_path
        end
      end
我正在重定向到我的根路径

我的根路径在My routes.rb文件中定义为:home#home

在我的视图文件夹中,我有一个名为home的文件夹,其中有一个名为home.html.erb的文件

我已在LinkedIn注册了重定向URL:www.xxxxxxx.com/home,并尝试了以下内容:www.xxxxxxx.com、www.xxxxxxx.com/views/home/home、www.xxxxxxx.com/home/home。这些路径都不起作用

请有人帮助我理解如何定义一个重定向路径,该路径能够被LinkedIn识别为匹配我的根路径


非常感谢您。

运行
rake routes
并查看URI模式以
回调结束

您很可能会发现这样的模式:

/users/auth/:action/callback(.:format)
这意味着在开发过程中,您的回调url将是:

http://localhost:3000/users/auth/linkedin/callback
www.xxxxxxx.com/users/auth/linkedin/callback
在生产中,您的回调url将是:

http://localhost:3000/users/auth/linkedin/callback
www.xxxxxxx.com/users/auth/linkedin/callback

非常感谢。那太好了。我也遇到了同样的问题,但这对我不起作用。它与facebook和google_oauth2合作,但与linked in不合作……我也与linkedin打交道。它无法很好地处理路径中的“用户”