我想在我的 Web 应用程序中使用 Yahoo Fantasy Sport API,为此我使用 OAuth 进行 Yahoo 登录。我有消费者密钥和秘密密钥,当我运行以下代码时,我成功传递了密钥。它重定向到雅虎登录,它要求访问用户凭据的权限。如果我同意页面重定向到https://api.login.yahoo.com/oauth/v2/request_auth并显示验证码。如果我在验证码页面中按下关闭按钮,它不会回调我的 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
你能告诉我要进行哪些更改以获取回调以获取 access_token。