getOAuthAccessToken method

Future<List<GetOAuthAccessToken200ResponseInner>?> getOAuthAccessToken(
  1. String userId,
  2. String provider, {
  3. bool? paginated,
  4. int? limit,
  5. int? offset,
})

Retrieve the OAuth access token of a user

Fetch the corresponding OAuth access token for a user that has previously authenticated with a particular OAuth provider. For OAuth 2.0, if the access token has expired and we have a corresponding refresh token, the access token will be refreshed transparently the new one will be returned.

Parameters:

  • String userId (required): The ID of the user for which to retrieve the OAuth access token

  • String provider (required): The ID of the OAuth provider (e.g. oauth_google)

  • bool paginated: Whether to paginate the results. If true, the results will be paginated. If false, the results will not be paginated.

  • int limit: Applies a limit to the number of results returned. Can be used for paginating the results together with offset.

  • int offset: Skip the first offset results when paginating. Needs to be an integer greater or equal to zero. To be used in conjunction with limit.

Implementation

Future<List<GetOAuthAccessToken200ResponseInner>?> getOAuthAccessToken(
  String userId,
  String provider, {
  bool? paginated,
  int? limit,
  int? offset,
}) async {
  final response = await getOAuthAccessTokenWithHttpInfo(
    userId,
    provider,
    paginated: paginated,
    limit: limit,
    offset: offset,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    final responseBody = await _decodeBodyBytes(response);
    return (await apiClient.deserializeAsync(
                responseBody, 'List<GetOAuthAccessToken200ResponseInner>')
            as List)
        .cast<GetOAuthAccessToken200ResponseInner>()
        .toList(growable: false);
  }
  return null;
}