setIdentityPoolRoles method
Sets the roles for an identity pool. These roles are used when making calls to GetCredentialsForIdentity action.
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. May throw ConcurrentModificationException.
Parameter identityPoolId
:
An identity pool ID in the format REGION:GUID.
Parameter roles
:
The map of roles associated with this pool. For a given role, the key will
be either "authenticated" or "unauthenticated" and the value will be the
Role ARN.
Parameter roleMappings
:
How users for a specific identity provider are to mapped to roles. This is
a string to RoleMapping object map. The string identifies the
identity provider, for example, "graph.facebook.com" or
"cognito-idp-east-1.amazonaws.com/us-east-1_abcdefghi:app_client_id".
Up to 25 rules can be specified per identity provider.
Implementation
Future<void> setIdentityPoolRoles({
required String identityPoolId,
required Map<String, String> roles,
Map<String, RoleMapping>? roleMappings,
}) async {
ArgumentError.checkNotNull(identityPoolId, 'identityPoolId');
_s.validateStringLength(
'identityPoolId',
identityPoolId,
1,
55,
isRequired: true,
);
ArgumentError.checkNotNull(roles, 'roles');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityService.SetIdentityPoolRoles'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'IdentityPoolId': identityPoolId,
'Roles': roles,
if (roleMappings != null) 'RoleMappings': roleMappings,
},
);
}