mergeDeveloperIdentities method

Future<MergeDeveloperIdentitiesResponse> mergeDeveloperIdentities({
  1. required String destinationUserIdentifier,
  2. required String developerProviderName,
  3. required String identityPoolId,
  4. required String sourceUserIdentifier,
})

Merges two users having different IdentityIds, existing in the same identity pool, and identified by the same developer provider. You can use this action to request that discrete users be merged and identified as a single user in the Cognito environment. Cognito associates the given source user (SourceUserIdentifier) with the IdentityId of the DestinationUserIdentifier. Only developer-authenticated users can be merged. If the users to be merged are associated with the same public provider, but as two different users, an exception will be thrown.

The number of linked logins is limited to 20. So, the number of linked logins for the source user, SourceUserIdentifier, and the destination user, DestinationUserIdentifier, together should not be larger than 20. Otherwise, an exception will be thrown.

You must use AWS Developer credentials to call this API.

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

Parameter destinationUserIdentifier : User identifier for the destination user. The value should be a DeveloperUserIdentifier.

Parameter developerProviderName : The "domain" by which Cognito will refer to your users. This is a (pseudo) domain name that you provide while creating an identity pool. This name acts as a placeholder that allows your backend and the Cognito service to communicate about the developer provider. For the DeveloperProviderName, you can use letters as well as period (.), underscore (_), and dash (-).

Parameter identityPoolId : An identity pool ID in the format REGION:GUID.

Parameter sourceUserIdentifier : User identifier for the source user. The value should be a DeveloperUserIdentifier.

Implementation

Future<MergeDeveloperIdentitiesResponse> mergeDeveloperIdentities({
  required String destinationUserIdentifier,
  required String developerProviderName,
  required String identityPoolId,
  required String sourceUserIdentifier,
}) async {
  ArgumentError.checkNotNull(
      destinationUserIdentifier, 'destinationUserIdentifier');
  _s.validateStringLength(
    'destinationUserIdentifier',
    destinationUserIdentifier,
    1,
    1024,
    isRequired: true,
  );
  ArgumentError.checkNotNull(developerProviderName, 'developerProviderName');
  _s.validateStringLength(
    'developerProviderName',
    developerProviderName,
    1,
    128,
    isRequired: true,
  );
  ArgumentError.checkNotNull(identityPoolId, 'identityPoolId');
  _s.validateStringLength(
    'identityPoolId',
    identityPoolId,
    1,
    55,
    isRequired: true,
  );
  ArgumentError.checkNotNull(sourceUserIdentifier, 'sourceUserIdentifier');
  _s.validateStringLength(
    'sourceUserIdentifier',
    sourceUserIdentifier,
    1,
    1024,
    isRequired: true,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityService.MergeDeveloperIdentities'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'DestinationUserIdentifier': destinationUserIdentifier,
      'DeveloperProviderName': developerProviderName,
      'IdentityPoolId': identityPoolId,
      'SourceUserIdentifier': sourceUserIdentifier,
    },
  );

  return MergeDeveloperIdentitiesResponse.fromJson(jsonResponse.body);
}