Skip to content

Instantly share code, notes, and snippets.

@MichaelEvans
Forked from tpitale/oauth_signin.rb
Created March 28, 2013 15:47
Show Gist options
  • Save MichaelEvans/5264233 to your computer and use it in GitHub Desktop.
Save MichaelEvans/5264233 to your computer and use it in GitHub Desktop.
# ----------------- OAUTH CONSUMER ------------------
consumer = OAuth::Consumer.new('anonymous', 'anonymous', {
:site => 'https://www.google.com',
:request_token_path => '/accounts/OAuthGetRequestToken',
:access_token_path => '/accounts/OAuthGetAccessToken',
:authorize_path => '/accounts/OAuthAuthorizeToken'
})
# ----------------- NEW OAUTH TOKEN ------------------
request_token = consumer.get_request_token({}, {:scope => 'https://www.google.com/analytics/feeds'})
puts request_token.authorize_url # gives us the verifier, enter it in a url
# access_token = request_token.get_access_token(:oauth_verifier => '') # paste in the info from google
# pull out the secret and token from the above access token, and save in strings for later
# ----------------- OAUTH INFO FOR xxx ------------------
# secret = ''
# token = ''
# access_token = OAuth::AccessToken.new(consumer, token, secret)
Garb::Session.access_token = access_token # apply the access_token
# session.access_token = access_token # or apply to an individual session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment