class IdonethisCli::Client::Auth

Attributes

api_token[R]
error[R]

Public Instance Methods

authenticate() click to toggle source
# File lib/idonethis_cli/client/auth.rb, line 6
def authenticate()
  # TODO
end
oauth2_client() click to toggle source
# File lib/idonethis_cli/client/auth.rb, line 10
def oauth2_client
  @oauth2_client ||= OAuth2::Client.new(CLIENT_ID, CLIENT_SECRET, site: BASE_URL)
end
oauth2_token(code) click to toggle source
# File lib/idonethis_cli/client/auth.rb, line 18
def oauth2_token(code)
  oauth2_client.auth_code.get_token(code, redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
end
token(oauth2_token) click to toggle source
# File lib/idonethis_cli/client/auth.rb, line 22
def token(oauth2_token)
  current_token = OAuth2::AccessToken.from_hash(oauth2_client, oauth2_token)
  current_token.expired? ? current_token.refresh! : current_token
end
url() click to toggle source
# File lib/idonethis_cli/client/auth.rb, line 14
def url
  oauth2_client.auth_code.authorize_url(redirect_uri: 'urn:ietf:wg:oauth:2.0:oob')
end