Ruby'de oAuth isteği yapmak istiyorum. Bazı örnekler eksik ama hiçbiri ve oauth_token
almak için consumer_key
ve consumer_secret
sadece oauth_token_secret and oauth_token
kullandı. Ama ben zaten oauth_token_secret
ve oauth_token
var.Bir oAuth jetonu ile bir API çağrısı yapmak için
consumer_key = "anonymous"
consumer_secret = "anonymous"
oauth_token_secret = "fdsfdsfdfdsfds"
oauth_token = "fdsfdsfdfdsfdsdsdsdsdsdsds"
bir API isteği yapmak için, Yani ne yapmak gerekir edilir:
Örneğin, ben denedim bu benim durumda
require 'rubygems'
require 'oauth'
consumer = OAuth::Consumer.new(consumer_key, consumer_secret,
{
:site=> "https://www.google.com",
:scheme=> :header,
:http_method=> :post,
:request_token_path => "/accounts/OAuthGetRequestToken",
:access_token_path => "/accounts/OAuthGetAccessToken",
:authorize_path=> "/accounts/OAuthAuthorizeToken",
:signature_method=>"RSA-SHA1"},
# :private_key_file=>PATH_TO_PRIVATE_KEY
)
request_token = consumer.get_request_token()
puts "Visit the following URL, log in if you need to, and authorize the app"
puts request_token.authorize_url
puts "When you've authorized that token, enter the verifier code you are assigned:"
verifier = gets.strip
puts "Converting request token into access token..."
access_token=request_token.get_access_token(:oauth_verifier => verifier)
puts "access_token.token --> #{access_token.token}" # But I initially have it
puts "access_token.secret --> #{access_token.secret}" # But I initially have it
kullanmak, 4 gizli anahtarlar vardır Bazı ek alma parametreleri ve oAuth belirteci ile belirli url için ve cevabı almak için.
Bunu Ruby'de nasıl yapıyorum?
OAuth :: AccessToken'i almam gerek çünkü o zaten oauth_secret ve oauth_token. –
@AlanDert biliyorum. Buraya ulaştığınız nesneyi kullanın: 'access_token = request_token.get_access_token (: oauth_verifier => verifier)' – oldergod
Doğrulayıcı nedir? Tam bir örnek verebilir misiniz lütfen? Dikkat edin, Typhoeus'un bir hatası var, kullanamıyorum. –