Rails - OAuth::问题异常:LinkedIn API 中的parameter_absent
我正在使用 Oauth gem 开发 APi 中的链接。同样的 gem 对于我的 Twitter API 来说工作得很好,但是对于 Linkedin API,我正在获取请求令牌,当它尝试获取访问令牌时,它会返回错误
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
谢谢..
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::Problem Exception: parameter_absent
Code is as follows..
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
Thank you..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后我做到了,“:oauth_verifier => params [:oauth_verifier]”这就是问题:)
Finally i did it, ":oauth_verifier => params[:oauth_verifier]" this was the problem :)
我遇到了同样的问题,您可以使用 https://github.com/decioferreira/omniauth 修复它-linkedin-oauth2
I got the same problem, you can fix it by using https://github.com/decioferreira/omniauth-linkedin-oauth2