Module: WeConnect::Authentication

Included in:
API
Defined in:
lib/weconnect/authorization.rb

Overview

Deals with authentication flow and stores it within global configuration

Defined Under Namespace

Classes: CarConnectInfo, IDKParser, PasswordFormParser, WebLogin

Constant Summary collapse

TOKENS =
%w(state id_token access_token code)
TOKEN_URL =
'https://emea.bff.cariad.digital/user-login/login/v1'.freeze
REFRESH_URL =
'https://emea.bff.cariad.digital/user-login/refresh/v1'.freeze

Instance Method Summary collapse

Instance Method Details

#api_process_token(tokens) ⇒ Object



27
28
29
30
31
32
# File 'lib/weconnect/authorization.rb', line 27

def api_process_token(tokens)
  self.access_token  = tokens['access_token']
  self.token_type    = tokens['token_type']
  self.refresh_token = tokens['refresh_token']
  self.token_expires = tokens['expires_at'] if tokens['expires_at']
end

#auth_tokensObject



24
25
26
# File 'lib/weconnect/authorization.rb', line 24

def auth_tokens
  @tokens
end

#login(options = {}) ⇒ Object

Authorize to the WeConnect portal

Raises:



14
15
16
17
18
19
20
21
22
23
# File 'lib/weconnect/authorization.rb', line 14

def (options = {})
  raise ConfigurationError, "username/password not set" unless username && password
  # only bearer token needed
  car = CarConnectInfo.new

  @tokens = WebLogin.new(self,car).
  api_process_token(@tokens)
  reauth_connection(self.access_token)
  self.access_token
end

#refresh_tokenObject



34
35
36
# File 'lib/weconnect/authorization.rb', line 34

def refresh_token
  raise Error.new 'not implemented'
end