module Appilf::Authentication

Constants

PATH

Attributes

access_token[RW]
password[RW]
token_type[RW]
user[RW]
username[RW]

Public Instance Methods

authenticate() click to toggle source
# File lib/appilf/authentication.rb, line 13
def authenticate
  auth_by_password if username && password
end
authenticated_user_path() click to toggle source
# File lib/appilf/authentication.rb, line 21
def authenticated_user_path
  users_path(user.id)
end
authentication_headers() click to toggle source
# File lib/appilf/authentication.rb, line 17
def authentication_headers
  { Authorization: self.access_token }
end

Private Instance Methods

auth_by_password() click to toggle source
# File lib/appilf/authentication.rb, line 27
def auth_by_password
  response = api_post(PATH,{ grant_type: 'password',
                                                    username: username,
                                                    password: password
                                                    })
  self.access_token = response['access_token']
  self.token_type = response['token_type']
end