28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/flickr/authenticator.rb', line 28
def authenticate
token = flickr.get_request_token
auth_url = flickr.get_authorize_url(token['oauth_token'], :perms => 'delete')
puts "Open this url in your browser to complete the authentication process : #{auth_url}"
puts "Copy here the number given when you complete the process."
verify = gets.strip
begin
flickr.get_access_token(token['oauth_token'], token['oauth_token_secret'], verify)
login = flickr.test.login
puts "You are now authenticated as #{login.username} with token #{flickr.access_token} and secret #{flickr.access_secret}"
File.write('authkey.json', { access_token: flickr.access_token, secret: flickr.access_secret }.to_json)
flickr
rescue FlickRaw::FailedResponse => e
puts "Authentication failed : #{e.msg}"
end
end
|