getWebIdentityToken method
Returns a signed JSON Web Token (JWT) that represents the calling Amazon Web Services identity. The returned JWT can be used to authenticate with external services that support OIDC discovery. The token is signed by Amazon Web Services STS and can be publicly verified using the verification keys published at the issuer's JWKS endpoint.
May throw JWTPayloadSizeExceededException.
May throw OutboundWebIdentityFederationDisabledException.
May throw SessionDurationEscalationException.
Parameter audience :
The intended recipient of the web identity token. This value populates the
aud claim in the JWT and should identify the service or
application that will validate and use the token. The external service
should verify this claim to ensure the token was intended for their use.
Parameter signingAlgorithm :
The cryptographic algorithm to use for signing the JSON Web Token (JWT).
Valid values are RS256 (RSA with SHA-256) and ES384 (ECDSA using P-384
curve with SHA-384).
Parameter durationSeconds :
The duration, in seconds, for which the JSON Web Token (JWT) will remain
valid. The value can range from 60 seconds (1 minute) to 3600 seconds (1
hour). If not specified, the default duration is 300 seconds (5 minutes).
The token is designed to be short-lived and should be used for proof of
identity, then exchanged for credentials or short-lived tokens in the
external service.
Parameter tags :
An optional list of tags to include in the JSON Web Token (JWT). These
tags are added as custom claims to the JWT and can be used by the
downstream service for authorization decisions.
Implementation
Future<GetWebIdentityTokenResponse> getWebIdentityToken({
required List<String> audience,
required String signingAlgorithm,
int? durationSeconds,
List<Tag>? tags,
}) async {
_s.validateNumRange(
'durationSeconds',
durationSeconds,
60,
3600,
);
final $request = <String, String>{
if (audience.isEmpty)
'Audience': ''
else
for (var i1 = 0; i1 < audience.length; i1++)
'Audience.member.${i1 + 1}': audience[i1],
'SigningAlgorithm': signingAlgorithm,
if (durationSeconds != null)
'DurationSeconds': durationSeconds.toString(),
if (tags != null)
if (tags.isEmpty)
'Tags': ''
else
for (var i1 = 0; i1 < tags.length; i1++)
for (var e3 in tags[i1].toQueryMap().entries)
'Tags.member.${i1 + 1}.${e3.key}': e3.value,
};
final $result = await _protocol.send(
$request,
action: 'GetWebIdentityToken',
version: '2011-06-15',
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
resultWrapper: 'GetWebIdentityTokenResult',
);
return GetWebIdentityTokenResponse.fromXml($result);
}