getOpenIdToken method

Future<GetOpenIdTokenResponse> getOpenIdToken({
  1. required String identityId,
  2. Map<String, String>? logins,
})

Gets an OpenID token, using a known Cognito ID. This known Cognito ID is returned by GetId. You can optionally add additional logins for the identity. Supplying multiple logins creates an implicit link.

The OpenId token is valid for 10 minutes.

This is a public API. You do not need any credentials to call this API.

May throw InvalidParameterException. May throw ResourceNotFoundException. May throw NotAuthorizedException. May throw ResourceConflictException. May throw TooManyRequestsException. May throw InternalErrorException. May throw ExternalServiceException.

Parameter identityId : A unique identifier in the format REGION:GUID.

Parameter logins : A set of optional name-value pairs that map provider names to provider tokens. When using graph.facebook.com and www.amazon.com, supply the access_token returned from the provider's authflow. For accounts.google.com, an Amazon Cognito user pool provider, or any other OpenId Connect provider, always include the id_token.

Implementation

Future<GetOpenIdTokenResponse> getOpenIdToken({
  required String identityId,
  Map<String, String>? logins,
}) async {
  ArgumentError.checkNotNull(identityId, 'identityId');
  _s.validateStringLength(
    'identityId',
    identityId,
    1,
    55,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityService.GetOpenIdToken'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    signed: false,
    // TODO queryParams
    headers: headers,
    payload: {
      'IdentityId': identityId,
      if (logins != null) 'Logins': logins,
    },
  );

  return GetOpenIdTokenResponse.fromJson(jsonResponse.body);
}