getAccessToken method

Future<String?> getAccessToken()

Get access token return Future

Implementation

Future<String?> getAccessToken() async {
  if (this._access_token != null) {
    return this._access_token;
  }

  Map<String, String?> data_app_client = {
    'client_id': this._client_id,
    'client_secret': this._client_secret,
    'grant_type': 'client_credentials',
  };

  var access_data = await this._restClient.post('/oauth/token',
      data: data_app_client, contentType: _restClient.MIME_FORM);

  if (access_data['status'] == 200) {
    this._access_token = access_data['response']['access_token'];
    return this._access_token;
  }
  return null;
}