本文介绍了Rails - OAuth::Problem 异常:LinkedIn API 中的参数不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Oauth gem 开发 APi 中的链接.同样的 gem 非常适合我的 Twitter API,但是在 Linkedin API 的情况下,我正在获取请求令牌,当它尝试获取访问令牌时,它返回错误
I am Develoing a Linked in APi using Oauth gem. The same gem is working perfectly for my Twitter API, But in the case of Linkedin API, I am getting the request token, and when it tries to get the access token it return the error
OAuth::问题异常:parameter_absent
代码如下..
consumerKey = "*************************"
consumerSecret = "*************************"
callbackUrl = "http://localhost/"
apiURL = "https://api.linkedin.com"
request_token_path = "/uas/oauth/requestToken"
access_token_path = "/uas/oauth/accessToken"
authorize_path = "/uas/oauth/authorize"
@consumer = OAuth::Consumer.new(consumerKey,consumerSecret, {
:site => apiURL,
:scheme => :header,
:http_method => :post,
:request_token_path => request_token_path,
:access_token_path => access_token_path,
:authorize_path => authorize_path
})
unless(params["oauth_token"].nil?)
@request_token = session[:request_token]
@access_token = @request_token.get_access_token
else
@request_token = @consumer.get_request_token(:oauth_callback => callbackUrl)
firstUrl = @request_token.authorize_url(:oauth_callback => callbackUrl)
session[:request_token] = @request_token
redirect_to firstUrl
end
谢谢..
推荐答案
最后我做到了,":oauth_verifier => params[:oauth_verifier]" 这就是问题 :)
Finally i did it, ":oauth_verifier => params[:oauth_verifier]" this was the problem :)
unless(params["oauth_token"].nil?)
@request_token = session[:request_token]
@access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
else
@request_token = @consumer.get_request_token(:oauth_callback => callbackUrl)
firstUrl = @request_token.authorize_url(:oauth_callback => callbackUrl)
session[:request_token] = @request_token
redirect_to firstUrl
end
这篇关于Rails - OAuth::Problem 异常:LinkedIn API 中的参数不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!