Class: Kuva::Authorizer

Inherits:
Object
  • Object
show all
Defined in:
lib/kuva/authorizer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuthorizer

Returns a new instance of Authorizer.



10
11
12
13
# File 'lib/kuva/authorizer.rb', line 10

def initialize
  FlickRaw.api_key       = Kuva.api_key
  FlickRaw.shared_secret = Kuva.shared_secret
end

Instance Attribute Details

#outObject (readonly)

Returns the value of attribute out.



4
5
6
# File 'lib/kuva/authorizer.rb', line 4

def out
  @out
end

Class Method Details

.authorizeObject



6
7
8
# File 'lib/kuva/authorizer.rb', line 6

def self.authorize
  new.authorize
end

Instance Method Details

#authorizeObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kuva/authorizer.rb', line 15

def authorize
  puts I18n.t("kuva.authentication.url", url: authentication_url)
  puts I18n.t("kuva.authentication.code")

  begin
    flickr.get_access_token oauth_token, oauth_token_secret, authorization_code
    puts I18n.t("kuva.authentication.success", account: flickr.test..username, api_key: Kuva.api_key, shared_secret: Kuva.shared_secret, access_token: flickr.access_token, access_secret: flickr.access_secret)
  rescue FlickRaw::OAuthClient::FailedResponse => error
    puts I18n.t("kuva.authentication.error", message: error)
  end
end