Client constructor

Client(
  1. Credentials _credentials, {
  2. String? identifier,
  3. String? secret,
  4. CredentialsRefreshedCallback? onCredentialsRefreshed,
  5. bool basicAuth = true,
  6. Client? httpClient,
})

Creates a new client from a pre-existing set of credentials.

When authorizing a client for the first time, you should use AuthorizationCodeGrant or resourceOwnerPasswordGrant instead of constructing a Client directly.

httpClient is the underlying client that this forwards requests to after adding authorization credentials to them.

Throws an ArgumentError if secret is passed without identifier.

Implementation

Client(this._credentials,
    {this.identifier,
    this.secret,
    CredentialsRefreshedCallback? onCredentialsRefreshed,
    bool basicAuth = true,
    http.Client? httpClient})
    : _basicAuth = basicAuth,
      _onCredentialsRefreshed = onCredentialsRefreshed,
      _httpClient = httpClient ?? http.Client() {
  if (identifier == null && secret != null) {
    throw ArgumentError('secret may not be passed without identifier.');
  }
}