Linkedin Ruby Gem(令牌在回调中被拒绝) [英] Linkedin Ruby Gem (token rejected in callback)

查看:59
本文介绍了Linkedin Ruby Gem(令牌在回调中被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 LinkedIn Ruby Gem 并遇到问题.这是我的rails服务器的输出.

I've been using the LinkedIn Ruby Gem and having a problem. Here is the output from my rails server.

Started GET "/session/callback?oauth_token=618b3bc2-d8f6-4c9c-99a2-10573c8b3c3c&oauth_verifier=09858" for 127.0.0.1 at Tue Jun 12 19:14:11 -0700 2012
Processing by SessionController#callback as HTML
  Parameters: {"oauth_verifier"=>"09858", "oauth_token"=>"618b3bc2-d8f6-4c9c-99a2-10573c8b3c3c"}
Completed 500 Internal Server Error in 163ms

OAuth::Problem (token_rejected):
  app/controllers/session_controller.rb:28:in `callback'


  Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_trace.erb (1.2ms)
  Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
  Rendered /Library/Ruby/Gems/1.8/gems/actionpack-3.2.3/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (12.9ms)

这是我的session_controller.rb中的代码:

Here is the code in my session_controller.rb:

require 'linkedin'

class SessionController < ApplicationController

  def login

    # get your api keys at https://www.linkedin.com/secure/developer
    client = LinkedIn::Client.new(APP_CONFIG['linkedin']['apikey'], APP_CONFIG['linkedin']['secret_key'])
    request_token = client.request_token(:oauth_callback => 
                                      "http://#{request.host_with_port}/session/callback")
    session[:rtoken] = request_token.token
    session[:rsecret] = request_token.secret

    redirect_to client.request_token.authorize_url

  end

  def logout
    session[:atoken] = nil
    redirect_to :root
  end

  def callback

    client = LinkedIn::Client.new(APP_CONFIG['linkedin']['apikey'], APP_CONFIG['linkedin']['secret_key']) # "your_api_key", "your_secret")
    if session[:atoken].nil?
      pin = params[:oauth_verifier]
      atoken, asecret = client.authorize_from_request(session[:rtoken], session[:rsecret], pin)
      session[:atoken] = atoken
      session[:asecret] = asecret
    else
      client.authorize_from_access(session[:atoken], session[:asecret])
    end

    redirect_to '/users/index'

  end

end

我也有随机访问问题,这是该错误:

I also have random access problems, here is the errors for that:

Access Denied
You don't have permission to access "/D/16382/14334/000/origin.wwwapps.ups.com/uas/oauth/authorize?oauth_token=730c3a62-08ad-4ac2-9281-c9e67bb3a2d5" on this server.

Reference #18.6fd054b8.1339554485.72cbb3 

推荐答案

请注意,这是否是该问题的最终答案,但是在开发过程中对我有帮助的一件事是清除了缓存和cookie.通常会出现此错误,因为在上一个会话中设置了cookie,这使系统感到困惑并触发了此错误.

Note sure if this is the ultimate answer for this question, but one thing that helped me during development was to clear my cache and cookies. Usually this error would come up because there were cookies set from a previous session that were confusing the system and triggering this error.

这篇关于Linkedin Ruby Gem(令牌在回调中被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆