Credentials constructor

Credentials(
  1. String accessToken, {
  2. String? refreshToken,
  3. String? idToken,
  4. Uri? tokenEndpoint,
  5. Iterable<String>? scopes,
  6. DateTime? expiration,
  7. String? delimiter,
  8. Map<String, dynamic> getParameters(
    1. MediaType? mediaType,
    2. String body
    )?,
})

Creates a new set of credentials.

This class is usually not constructed directly; rather, it's accessed via Client.credentials after a Client is created by AuthorizationCodeGrant. Alternately, it may be loaded from a serialized form via Credentials.fromJson.

The scope strings will be separated by the provided delimiter. This defaults to " ", the OAuth2 standard, but some APIs (such as Facebook's) use non-standard delimiters.

By default, this follows the OAuth2 spec and requires the server's responses to be in JSON format. However, some servers return non-standard response formats, which can be parsed using the getParameters function.

This function is passed the Content-Type header of the response as well as its body as a UTF-8-decoded string. It should return a map in the same format as the standard JSON response.

Implementation

Credentials(this.accessToken,
    {this.refreshToken,
    this.idToken,
    this.tokenEndpoint,
    Iterable<String>? scopes,
    this.expiration,
    String? delimiter,
    Map<String, dynamic> Function(MediaType? mediaType, String body)?
        getParameters})
    : scopes = UnmodifiableListView(
          // Explicitly type-annotate the list literal to work around
          // sdk#24202.
          scopes == null ? <String>[] : scopes.toList()),
      _delimiter = delimiter ?? ' ',
      _getParameters = getParameters ?? parseJsonParameters;