Class: Trellish::Auth

Inherits:
Object
  • Object
show all
Includes:
Trello, Trello::Authorization
Defined in:
lib/trellish/auth.rb

Constant Summary collapse

@@member =
nil

Class Method Summary collapse

Class Method Details

.authorizeObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trellish/auth.rb', line 13

def self.authorize
  return @@member if @@member

  OAuthPolicy.consumer_credential = OAuthCredential.new(
    Trellish.config[:trello_api_key],
    Trellish.config[:trello_oauth_secret])
  OAuthPolicy.token = OAuthCredential.new(Trellish.config[:trello_oauth_token], nil)

  # Test that the user is authorized
  begin
    member_id = Trello::Token.find(OAuthPolicy.token.key).member_id
    @@member = Member.find(member_id)
    @@member
  rescue
    Trellish.logger.error "Unable to authorize access to Trello API."
    exit
  end
end