Created
September 1, 2010 02:55
-
-
Save leshill/560151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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