createIdentityPool method

Future<IdentityPool> createIdentityPool({
  1. required bool allowUnauthenticatedIdentities,
  2. required String identityPoolName,
  3. bool? allowClassicFlow,
  4. List<CognitoIdentityProvider>? cognitoIdentityProviders,
  5. String? developerProviderName,
  6. Map<String, String>? identityPoolTags,
  7. List<String>? openIdConnectProviderARNs,
  8. List<String>? samlProviderARNs,
  9. Map<String, String>? supportedLoginProviders,
})

Creates a new identity pool. The identity pool is a store of user identity information that is specific to your Amazon Web Services account. The keys for SupportedLoginProviders are as follows:

  • Facebook: graph.facebook.com
  • Google: accounts.google.com
  • Sign in With Apple: appleid.apple.com
  • Amazon: www.amazon.com
  • Twitter: api.twitter.com
  • Digits: www.digits.com
You must use Amazon Web Services developer credentials to call this operation.

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

Parameter allowUnauthenticatedIdentities : TRUE if the identity pool supports unauthenticated logins.

Parameter identityPoolName : A string that you provide.

Parameter allowClassicFlow : Enables or disables the Basic (Classic) authentication flow. For more information, see Identity Pools (Federated Identities) Authentication Flow in the Amazon Cognito Developer Guide.

Parameter cognitoIdentityProviders : An array of Amazon Cognito user pools and their client IDs.

Parameter developerProviderName : The "domain" by which Cognito will refer to your users. 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 (-).

Once you have set a developer provider name, you cannot change it. Please take care in setting this parameter.

Parameter identityPoolTags : Tags to assign to the identity pool. A tag is a label that you can apply to identity pools to categorize and manage them in different ways, such as by purpose, owner, environment, or other criteria.

Parameter openIdConnectProviderARNs : The Amazon Resource Names (ARN) of the OpenID Connect providers.

Parameter samlProviderARNs : An array of Amazon Resource Names (ARNs) of the SAML provider for your identity pool.

Parameter supportedLoginProviders : Optional key:value pairs mapping provider names to provider app IDs.

Implementation

Future<IdentityPool> createIdentityPool({
  required bool allowUnauthenticatedIdentities,
  required String identityPoolName,
  bool? allowClassicFlow,
  List<CognitoIdentityProvider>? cognitoIdentityProviders,
  String? developerProviderName,
  Map<String, String>? identityPoolTags,
  List<String>? openIdConnectProviderARNs,
  List<String>? samlProviderARNs,
  Map<String, String>? supportedLoginProviders,
}) async {
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AWSCognitoIdentityService.CreateIdentityPool'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'AllowUnauthenticatedIdentities': allowUnauthenticatedIdentities,
      'IdentityPoolName': identityPoolName,
      if (allowClassicFlow != null) 'AllowClassicFlow': allowClassicFlow,
      if (cognitoIdentityProviders != null)
        'CognitoIdentityProviders': cognitoIdentityProviders,
      if (developerProviderName != null)
        'DeveloperProviderName': developerProviderName,
      if (identityPoolTags != null) 'IdentityPoolTags': identityPoolTags,
      if (openIdConnectProviderARNs != null)
        'OpenIdConnectProviderARNs': openIdConnectProviderARNs,
      if (samlProviderARNs != null) 'SamlProviderARNs': samlProviderARNs,
      if (supportedLoginProviders != null)
        'SupportedLoginProviders': supportedLoginProviders,
    },
  );

  return IdentityPool.fromJson(jsonResponse.body);
}