getIdentityContext method
Retrieves the identity context for a Quick Sight user in a specified namespace, allowing you to obtain identity tokens that can be used with identity-enhanced IAM role sessions to call identity-aware APIs.
Currently, you can call the following APIs with identity-enhanced Credentials
Supported Authentication MethodsThis API supports Quick Sight native users, IAM federated users, and Active Directory users. For Quick Sight users authenticated by Amazon Web Services Identity Center, see Identity Center documentation on identity-enhanced IAM role sessions.
Supported Regions
The GetIdentityContext API works only in regions that support at least one of these identity types:
- Amazon Quick Sight native identity
- IAM federated identity
- Active Directory
Getting Identity-Enhanced Credentials
To obtain identity-enhanced credentials, follow these steps:
- Call the GetIdentityContext API to retrieve an identity token for the specified user.
- Use the identity token with the STS AssumeRole API to obtain identity-enhanced IAM role session credentials.
The identity token returned by this API should be used with the STS
AssumeRole API to obtain credentials for an identity-enhanced IAM role
session. When calling AssumeRole, include the identity token in the
ProvidedContexts parameter with ProviderArn set
to arn:aws:iam::aws:contextProvider/QuickSight and
ContextAssertion set to the identity token received from this
API.
The assumed role must allow the sts:SetContext action in
addition to sts:AssumeRole in its trust relationship policy.
The trust policy should include both actions for the principal that will
be assuming the role.
May throw AccessDeniedException.
May throw InternalFailureException.
May throw InvalidParameterValueException.
May throw PreconditionNotMetException.
May throw ResourceNotFoundException.
May throw ThrottlingException.
Parameter awsAccountId :
The ID for the Amazon Web Services account that the user whose identity
context you want to retrieve is in. Currently, you use the ID for the
Amazon Web Services account that contains your Quick Sight account.
Parameter userIdentifier :
The identifier for the user whose identity context you want to retrieve.
Parameter contextRegion :
The region in which the context is to be used. Use this parameter to
obtain an identity context for cross-region use.
The specified region must meet the following conditions:
-
The region must be in the same Amazon Web Services partition as the region
you are calling from. Cross-partition requests are not supported. For
example, you cannot specify a region in the
aws-cnpartition when calling from a region in theawspartition. - It must be a valid Amazon QuickSight supported region.
- The calling customer account must be enabled in the specified context region.
- This parameter is not supported when calling from an opt-in region.
Parameter namespace :
The namespace of the user that you want to get identity context for. This
parameter is required when the UserIdentifier is specified using Email or
UserName.
Parameter sessionExpiresAt :
The timestamp at which the session will expire.
Implementation
Future<GetIdentityContextResponse> getIdentityContext({
required String awsAccountId,
required UserIdentifier userIdentifier,
String? contextRegion,
String? namespace,
DateTime? sessionExpiresAt,
}) async {
final $payload = <String, dynamic>{
'UserIdentifier': userIdentifier,
if (contextRegion != null) 'ContextRegion': contextRegion,
if (namespace != null) 'Namespace': namespace,
if (sessionExpiresAt != null)
'SessionExpiresAt': unixTimestampToJson(sessionExpiresAt),
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/accounts/${Uri.encodeComponent(awsAccountId)}/identity-context',
exceptionFnMap: _exceptionFns,
);
return GetIdentityContextResponse.fromJson(response);
}