Skip to content

STSClient.get_session_token

rboto-sts==0.4.0 · Service index · Types

Model summary (excerpt): Returns a set of temporary credentials for an Amazon Web Services account or IAM user. The credentials consist of an access key ID, a secret access key, and a security token. Typically, you use GetSessionToken if you want to use MFA to protect programmatic calls to specific Amazon Web Services API operations like Amazon EC2 StopInstances . MFA-enabled IAM users must call GetSessionToken and...

Install and imports

python -m pip install "rboto[sts]==0.4.0"
from rboto import STSClient
from rboto_sts.types import (
    GetSessionTokenOutput,
)

Signature

async def get_session_token(
    *,
    duration_seconds: int | None = None,
    serial_number: str | None = None,
    token_code: str | None = None,
    minimum_session_token_size: int | None = None,
) -> GetSessionTokenOutput: ...

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)
duration_seconds No The duration, in seconds, that the credentials should remain valid. Acceptable durations for IAM user sessions range from 900 seconds (15 minutes) to 129,600 seconds (36 hours), with 43,200 seconds (12 hours) as the default. Sessions for Amazon Web Services account owners are restricted to a maximum of 3,600 seconds (one hour). If the duration is longer than one hour, the session for Amazon...
serial_number No The identification number of the MFA device that is associated with the IAM user who is making the GetSessionToken call. Specify this value if the IAM user has a policy that requires MFA authentication. The value is either the serial number for a hardware device (such as GAHT12345678 ) or an Amazon Resource Name (ARN) for a virtual device (such as arn:aws:iam::123456789012:mfa/user ). You can...
token_code No The value provided by the MFA device, if MFA is required. If any policy requires the IAM user to submit an MFA code, specify this value. If MFA authentication is required, the user must provide a code when requesting a set of temporary security credentials. A user who fails to provide the code receives an "access denied" response when requesting resources that require MFA authentication. The...
minimum_session_token_size No

Output

GetSessionTokenOutput.

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
session_token_utilization int | None Always present —
session_token_size int | None Always present —

| 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.

GetSessionTokenOutput

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:

RegionDisabledError.

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

Service guide · Pinned model