Rails - OAuth::问题异常:LinkedIn API 中的parameter_absent

发布于 2024-11-19 18:22:22 字数 1530 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回眸一遍 2024-11-26 18:22:22

最后我做到了,“:oauth_verifier => params [:oauth_verifier]”这就是问题:)

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

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
帅冕 2024-11-26 18:22:22

我遇到了同样的问题,您可以使用 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文