createIdentityProvider method
Creates an identity provider for a user pool.
May throw InvalidParameterException. May throw DuplicateProviderException. May throw ResourceNotFoundException. May throw NotAuthorizedException. May throw TooManyRequestsException. May throw LimitExceededException. May throw InternalErrorException.
Parameter providerDetails
:
The identity provider details. The following list describes the provider
detail keys for each identity provider type.
-
For Google and Login with Amazon:
- client_id
- client_secret
- authorize_scopes
-
For Facebook:
- client_id
- client_secret
- authorize_scopes
- api_version
-
For Sign in with Apple:
- client_id
- team_id
- key_id
- private_key
- authorize_scopes
-
For OIDC providers:
- client_id
- client_secret
- attributes_request_method
- oidc_issuer
- authorize_scopes
- authorize_url if not available from discovery URL specified by oidc_issuer key
- token_url if not available from discovery URL specified by oidc_issuer key
- attributes_url if not available from discovery URL specified by oidc_issuer key
- jwks_uri if not available from discovery URL specified by oidc_issuer key
-
For SAML providers:
- MetadataFile OR MetadataURL
- IDPSignout optional
Parameter providerName
:
The identity provider name.
Parameter providerType
:
The identity provider type.
Parameter userPoolId
:
The user pool ID.
Parameter attributeMapping
:
A mapping of identity provider attributes to standard and custom user pool
attributes.
Parameter idpIdentifiers
:
A list of identity provider identifiers.
Implementation
Future<CreateIdentityProviderResponse> createIdentityProvider({
required Map<String, String> providerDetails,
required String providerName,
required IdentityProviderTypeType providerType,
required String userPoolId,
Map<String, String>? attributeMapping,
List<String>? idpIdentifiers,
}) async {
ArgumentError.checkNotNull(providerDetails, 'providerDetails');
ArgumentError.checkNotNull(providerName, 'providerName');
_s.validateStringLength(
'providerName',
providerName,
1,
32,
isRequired: true,
);
ArgumentError.checkNotNull(providerType, 'providerType');
ArgumentError.checkNotNull(userPoolId, 'userPoolId');
_s.validateStringLength(
'userPoolId',
userPoolId,
1,
55,
isRequired: true,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityProviderService.CreateIdentityProvider'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'ProviderDetails': providerDetails,
'ProviderName': providerName,
'ProviderType': providerType.toValue(),
'UserPoolId': userPoolId,
if (attributeMapping != null) 'AttributeMapping': attributeMapping,
if (idpIdentifiers != null) 'IdpIdentifiers': idpIdentifiers,
},
);
return CreateIdentityProviderResponse.fromJson(jsonResponse.body);
}