authenticate method

Future<void> authenticate()

Authenticates this CurrencyCloud using its loginId and apiKey. CurrencyCloud will authenticate automatically if a Request is sent without authenticating or when the Authentication Token expires.

Implementation

Future<void> authenticate() async {
  var authUri = baseUri + '/authenticate/api';

  var body = {
    'login_id': loginId,
    'api_key': apiKey,
  };

  log.finest('Sending authentication request to url: $authUri');
  log.finest('body: $body');

  var response = await http.post(Uri.parse(authUri), body: body);
  var responseMap = _decodeResponse(response);

  log.finest('Got response Token: ${responseMap['auth_token']}');

  _authToken.value = responseMap['auth_token'] as String?;
}