Skip to content

Instantly share code, notes, and snippets.

@leshill
Created September 1, 2010 02:55
Show Gist options
  • Save leshill/560151 to your computer and use it in GitHub Desktop.
Save leshill/560151 to your computer and use it in GitHub Desktop.
def access_token
@access_token ||= begin
twitter_request = session['twitter_request']
oauth.authorize_from_request(twitter_request.token, twitter_request.secret, params['oauth_verifier'])
oauth.access_token
end
end
def oauth(opts = {})
@oauth ||= ::Twitter::OAuth.new(config.twitter_api_keys['token'], config.twitter_api_keys['secret'], opts)
end
def request_token
@request_token ||= oauth(:sign_in => true).request_token(:oauth_callback => callback_url)
end
# Request auth from Twitter
session['twitter_request'] = request_token
redirect! request_token.authorize_url
# Twitter redirects back to callback_url with oauth_verifier from Twitter as param
user.token = access_token.token
user.secret = access_token.secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment