我将 omiauth 与 ROR 一起使用,但出现以下错误,
omniauth 身份验证/失败消息=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
请帮我。
提前致谢