omn​​iauth auth / failure message = invalid_credentials

时间:2012-04-09 12:22:12

标签: ruby-on-rails omniauth linkedin

我正在使用带有ROR的omiauth,我收到以下错误,

omniauth auth / failure message = invalid_credentials,

我能够与linkedin连接,在给出页面重定向发生的所有内容后,我被要求提供用户凭据,我收到了上述错误。

这是我的回调:

class SessionsController < ApplicationController
        def create
          auth = request.env["omniauth.auth"]
          user = User.find_by_provider_and_uid(auth["provider"], auth["uid"]) || User.create_with_omniauth(auth)
          session[:user_id] = user.id
          redirect_to root_url, :notice => "Signed in!"
        end

        def destroy
          session[:user_id] = nil
          redirect_to root_url, :notice => "Signed out!"
        end
end

并且routes.rb是

Lovelinkedin::Application.routes.draw do
  root :to => "users#index" 

  match "/auth/:provider/callback" => "sessions#create"
  match "/auth/failure" => "users#index"
  match "/signout" => "sessions#destroy", :as => :signout

end

我的omniauth.rb是

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :linkedin, 'xxxxx', 'ffffffff'
end

请帮帮我。

提前致谢

1 个答案:

答案 0 :(得分:0)

您的omniuth.config.full_host在您的omniauth.rb文件中等于什么?

如果它重定向到安全站点,那么它应该是这样的:  “https://开头#{SITE_BASE}”

如果它不是一个安全的网站,那么就把它取下来