Skip to content

Instantly share code, notes, and snippets.

@tpitale
Created November 15, 2011 17:18
Show Gist options
  • Select an option

  • Save tpitale/1367666 to your computer and use it in GitHub Desktop.

Select an option

Save tpitale/1367666 to your computer and use it in GitHub Desktop.
OAuth Example for Garb
# ----------------- 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