6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/flickr/authenticator.rb', line 6
def authenticate(should_retry = true)
flickr = FlickRaw::Flickr.new(api_key: ENV['FLICKR_API_KEY'], shared_secret: ENV['FLICKR_SHARED_SECRET'])
if File.exist? 'authkey.json'
auth_key = JSON.parse(File.read('authkey.json'))
flickr.access_token = auth_key['access_token']
flickr.access_secret = auth_key['secret']
end
begin
flickr.test.login
rescue StandardError => e
raise unless should_retry
oauth(flickr)
authenticate(false)
end
flickr
end
|