Ruby on rails 雅虎OAuth 1.0回调问题?

Ruby on rails 雅虎OAuth 1.0回调问题?,ruby-on-rails,oauth,omniauth,yahoo-api,yahoo-oauth,Ruby On Rails,Oauth,Omniauth,Yahoo Api,Yahoo Oauth,我想在我的web应用程序中使用Yahoo Fantasy sport API,因为我使用OAuth登录Yahoo。我有使用者密钥和秘密密钥,并且在运行以下代码时成功地传递了密钥。它重定向到Yahoo登录,请求访问用户凭据的权限。如果我同意,页面将重定向到,并显示验证代码。如果我在验证码页面中按下关闭按钮,它不会回调到我的URL @ts=Time.now.to_i @callback_url = "http://localhost:3000/callback" @nonce =

我想在我的web应用程序中使用Yahoo Fantasy sport API,因为我使用OAuth登录Yahoo。我有使用者密钥和秘密密钥,并且在运行以下代码时成功地传递了密钥。它重定向到Yahoo登录,请求访问用户凭据的权限。如果我同意,页面将重定向到,并显示验证代码。如果我在验证码页面中按下关闭按钮,它不会回调到我的URL

 @ts=Time.now.to_i
    @callback_url = "http://localhost:3000/callback"
    @nonce = SecureRandom.hex()

       consumer = OAuth::Consumer.new("my consumerkey","secret key",
          { :site => 'https://api.login.yahoo.com', 
          :http_method => :post, 
          :scheme => :header,
          :oauth_nonce => @nonce,
          :request_token_path => '/oauth/v2/get_request_token', 
          :authorize_path => '/oauth/v2/request_auth', 
          :access_token_path => '/oauth/v2/get_token', 
          :oauth_callback => "http://localhost:3000/callback",
          :oauth_timestamp => Time.now.to_i,
          :oauth_signature_method => "HMAC-SHA-1",
          :oauth_version => "1.0",
          :oauth_callback_confirmed => true,
         })

    request_token = consumer.get_request_token
    session[:request_token]=request_token
    redirect_to request_token.authorize_url
    access_token=request_token.get_access_token
    access = ActiveSupport::JSON.decode(access_token.to_json)
     if !(access.present?)
      @response = "Response failed"  
    else
      @response = access  
    end

您能否告诉我,为了获取访问令牌,需要对回调进行哪些更改。

我认为您在获取回调时感到困惑。按如下方式更改代码,您肯定会获得访问令牌以进行Yahoo API调用

        @@access_token = nil
        @@request_token = nil
     def get_request_token
        @@consumer = OAuth::Consumer.new('consumer key',
                    'secret key',
                    {
                      :site                 => 'https://api.login.yahoo.com', 
                      :scheme               => :query_string, 
                      :http_method          => :get, 
                      :request_token_path   => '/oauth/v2/get_request_token', 
                      :access_token_path    => '/oauth/v2/get_token', 
                      :authorize_path       => '/oauth/v2/request_auth'
                })
                @@request_token = @@consumer.get_request_token( { :oauth_callback => 'http://localhost:3000/callback' } )
                session[:request_token]=@@request_token
                redirect_to @@request_token.authorize_url
                #redirect_to @@request_token.authorize_url( { :oauth_callback => 'http://localhost:3000/success' } )

     end


    def callback
    request_token = ActiveSupport::JSON.decode(@@request_token.to_json)

        if !(request_token.present?)
          $request_token_value = "Response failed"  
        else
          $request_token_value = request_token  
        end
        # access_token = @@request_token.get_access_token({:oauth_verifier=>params[:oauth_verifier],:oauth_token=>params[:oauth_token]}) 
        @@access_token =    @@request_token.get_access_token(:oauth_verifier=>params[:oauth_verifier]) 
        access_json = ActiveSupport::JSON.decode(@@access_token.to_json)
        puts "****************************"  
        puts $access_json
        puts "****************************"   
    end

谢谢你的回复,我会像你提到的那样尝试。