STS / Client / get_web_identity_token
get_web_identity_token¶
- STS.Client.get_web_identity_token(**kwargs)¶
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.
See also: AWS API Documentation
Request Syntax
response = client.get_web_identity_token( Audience=[ 'string', ], DurationSeconds=123, SigningAlgorithm='string', Tags=[ { 'Key': 'string', 'Value': 'string' }, ] )
- Parameters:
Audience (list) –
[REQUIRED]
The intended recipient of the web identity token. This value populates the
audclaim 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.(string) –
DurationSeconds (integer) – 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.
SigningAlgorithm (string) –
[REQUIRED]
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).
Tags (list) –
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.
(dict) –
You can pass custom key-value pair attributes when you assume a role or federate a user. These are called session tags. You can then use the session tags to control access to resources. For more information, see Tagging Amazon Web Services STS Sessions in the IAM User Guide.
Key (string) – [REQUIRED]
The key for a session tag.
You can pass up to 50 session tags. The plain text session tag keys can’t exceed 128 characters. For these and additional limits, see IAM and STS Character Limits in the IAM User Guide.
Value (string) – [REQUIRED]
The value for a session tag.
You can pass up to 50 session tags. The plain text session tag values can’t exceed 256 characters. For these and additional limits, see IAM and STS Character Limits in the IAM User Guide.
- Return type:
dict
- Returns:
Response Syntax
{ 'WebIdentityToken': 'string', 'Expiration': datetime(2015, 1, 1) }
Response Structure
(dict) –
WebIdentityToken (string) –
A signed JSON Web Token (JWT) that represents the caller’s Amazon Web Services identity. The token contains standard JWT claims such as subject, audience, expiration time, and additional identity attributes added by STS as custom claims. You can also add your own custom claims to the token by passing tags as request parameters to the
GetWebIdentityTokenAPI. The token is signed using the specified signing algorithm and can be verified using the verification keys available at the issuer’s JWKS endpoint.Expiration (datetime) –
The date and time when the web identity token expires, in UTC. The expiration is determined by adding the
DurationSecondsvalue to the time the token was issued. After this time, the token should no longer be considered valid.
Exceptions
STS.Client.exceptions.SessionDurationEscalationExceptionSTS.Client.exceptions.OutboundWebIdentityFederationDisabledExceptionSTS.Client.exceptions.JWTPayloadSizeExceededException