Skip to content

STSClient.assume_role_with_web_identity

rboto-sts==0.4.0 · Service index · Types

Model summary (excerpt): Returns a set of temporary security credentials for users who have been authenticated in a mobile or web application with a web identity provider. Example providers include the OAuth 2.0 providers Login with Amazon and Facebook, or any OpenID Connect-compatible identity provider such as Google or Amazon Cognito federated identities . For mobile applications, we recommend that you use Amazon...

Install and imports

python -m pip install "rboto[sts]==0.4.0"
from rboto import STSClient
from collections.abc import Sequence
from rboto_sts.types import (
    AssumeRoleWithWebIdentityOutput,
    PolicyDescriptorType,
)

Signature

async def assume_role_with_web_identity(
    *,
    role_arn: str,
    role_session_name: str,
    web_identity_token: str,
    provider_id: str | None = None,
    policy_arns: Sequence[PolicyDescriptorType] | None = None,
    policy: str | None = None,
    duration_seconds: int | None = None,
    minimum_session_token_size: int | None = None,
) -> AssumeRoleWithWebIdentityOutput: ...

Arguments without defaults are required. None omits an optional request argument. Static types do not validate resource existence, permissions, lengths, ranges, or conditional service requirements.

Arguments

Argument Required Model notes (excerpt)
role_arn Yes The Amazon Resource Name (ARN) of the role that the caller is assuming. Additional considerations apply to Amazon Cognito identity pools that assume cross-account IAM roles . The trust policies of these roles must accept the cognito-identity.amazonaws.com service principal and must contain the cognito-identity.amazonaws.com:aud condition key to restrict role assumption to users from your...
role_session_name Yes An identifier for the assumed role session. Typically, you pass the name or identifier that is associated with the user who is using your application. That way, the temporary security credentials that your application will use are associated with that user. This session name is included as part of the ARN and assumed role ID in the AssumedRoleUser response element. For security purposes,...
web_identity_token Yes The OAuth 2.0 access token or OpenID Connect ID token that is provided by the identity provider. Your application must get this token by authenticating the user who is using your application with a web identity provider before the application makes an AssumeRoleWithWebIdentity call. Timestamps in the token must be formatted as either an integer or a long integer. Tokens must be signed using...
provider_id No The fully qualified host component of the domain name of the OAuth 2.0 identity provider. Do not specify this value for an OpenID Connect identity provider. Currently www.amazon.com and graph.facebook.com are the only supported identity providers for OAuth 2.0 access tokens. Do not include URL schemes and port numbers. Do not specify this value for OpenID Connect ID tokens.
policy_arns No The Amazon Resource Names (ARNs) of the IAM managed policies that you want to use as managed session policies. The policies must exist in the same account as the role. This parameter is optional. You can provide up to 10 managed policy ARNs. However, the plaintext that you use for both inline and managed session policies can't exceed 2,048 characters. For more information about ARNs, see...
policy No An IAM policy in JSON format that you want to use as an inline session policy. This parameter is optional. Passing policies to this operation returns new temporary credentials. The resulting session's permissions are the intersection of the role's identity-based policy and the session policies. You can use the role's temporary credentials in subsequent Amazon Web Services API calls to access...
duration_seconds No The duration, in seconds, of the role session. The value can range from 900 seconds (15 minutes) up to the maximum session duration setting for the role. This setting can have a value from 1 hour to 12 hours. If you specify a value higher than this setting, the operation fails. For example, if you specify a session duration of 12 hours, but your administrator set the maximum session duration...
minimum_session_token_size No

Output

AssumeRoleWithWebIdentityOutput.

Read-only native attributes, accessed as response.field. Collection getters materialize Python values; to_dict() recursively materializes a mapping. Streams are consumed once.

Field Type Presence References
credentials CredentialsOutput | None Always present CredentialsOutput
subject_from_web_identity_token str | None Always present —
assumed_role_user AssumedRoleUserOutput | None Always present AssumedRoleUserOutput
packed_policy_size int | None Always present —
provider str | None Always present —
audience str | None Always present —
source_identity str | None Always present —
session_token_utilization int | None Always present —
session_token_size int | None Always present —
trusted_identity_propagation_context TrustedIdentityPropagationContextOutput | None Always present TrustedIdentityPropagationContextOutput

| None means a value can be absent. Output mappings include every declared key; optional input keys may be omitted. Unknown output enum/union variants are not automatically valid inputs.

AssumeRoleWithWebIdentityOutput, PolicyDescriptorType

Follow these links for nested inputs and outputs; recursive types link back to the same type page.

Pagination and streaming

No generated paginator for this operation.

No output stream.

Errors

Import from rboto_sts.exceptions:

ExpiredTokenError, IDPCommunicationError, IDPRejectedClaimError, InvalidIdentityTokenError, MalformedPolicyDocumentError, PackedPolicyTooLargeError, RegionDisabledError.

Other service failures use the service base error; credential, transport and timeout failures use shared errors.

Service guide · Pinned model