13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/models/twitter_auth/oauth_user.rb', line 13
def identify_or_create_from_access_token(token, secret=nil)
raise ArgumentError, 'Must authenticate with an OAuth::AccessToken or the string access token and secret.' unless (token && secret) || token.is_a?(OAuth::AccessToken)
token = OAuth::AccessToken.new(TwitterAuth.consumer, token, secret) unless token.is_a?(OAuth::AccessToken)
response = token.get(TwitterAuth.path_prefix + '/account/verify_credentials.json')
user_info = handle_response(response)
if user = User.(user_info['id'].to_s)
user.login = user_info['screen_name']
user.(user_info)
user.access_token = token.token
user.access_secret = token.secret
user.save
user
else
User.create_from_twitter_hash_and_token(user_info, token)
end
end
|