13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/givey_ruby/model.rb', line 13
def access_token
@access_token ||= begin
if self.respond_to?(:givey_token) && self.givey_token
api_token = OAuth2::AccessToken.new(api_client, self.givey_token)
elsif ENV['GIVEY_TOKEN']
api_token = OAuth2::AccessToken.new(api_client, ENV['GIVEY_TOKEN'])
elsif givey_token = token_from_file
api_token = OAuth2::AccessToken.new(api_client, givey_token)
else
api_token = api_client.client_credentials.get_token
token_to_file(api_token.token)
end
api_token
end
end
|