Skip to content

Instantly share code, notes, and snippets.

@Xegyn
Created September 25, 2012 23:55
Show Gist options
  • Save Xegyn/3785176 to your computer and use it in GitHub Desktop.
Save Xegyn/3785176 to your computer and use it in GitHub Desktop.
Sample : YQL Query Using Omniauth, Omniauth-Oauth and Omniauth-Yahoo
require 'oauth'
require 'oauth/consumer'
require 'oauth/token'
require 'omniauth-yahoo'
key = 'Xdj0yJmk9VFV…..'
secret = '478787sha878978950e….'
options = {
:access_token_path => '/oauth/v2/get_token',
:authorize_path => '/oauth/v2/request_auth',
:request_token_path => '/oauth/v2/get_request_token',
:site => 'https://api.login.yahoo.com'
}
consumer = Consumer.new key, secret, options
request_token = consumer.get_request_token
request_token.authorize_url
# redirect_to request_token.authorize_url
# When user returns create an access_token
access_token = request_token.get_access_token :oath_verifier => '<verifier>' # User goes to the request_token.authorize_url and enters the verifier here
yql = "SELECT * FROM social.profile WHERE guid=me"
response = consumer.request(:get, "http://query.yahooapis.com/v1/yql?q=#{URI.escape(yql)}&format=json", access_token)
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment