Returns details about the IAM user or role whose credentials are used to call the operation.
No permissions are required to perform this operation. If an administrator attaches a policy to your identity that explicitly denies access to the sts:GetCallerIdentity action, you can still perform this operation. Permissions are not required because the same information is returned when access is denied. To view an example response, see I Am Not Authorized to Perform: iam:DeleteVirtualMFADevice in the IAM User Guide.
Raises:
Examples:
To get details about a calling IAM user
This example shows a request and response made with the credentials for a user named Alice in the AWS account 123456789012.
>>> await client.get_caller_identity()
To get details about a calling user federated with AssumeRole
This example shows a request and response made with temporary credentials created by AssumeRole. The name of the assumed role is my-role-name, and the RoleSessionName is set to my-role-session-name.
>>> await client.get_caller_identity()
To get details about a calling user federated with GetFederationToken
This example shows a request and response made with temporary credentials created by using GetFederationToken. The Name parameter is set to my-federated-user-name.
>>> await client.get_caller_identity()
Source code in docs_src/capo_sts/_services/async_sts.py
| async def get_caller_identity(
self, *, config_overrides: Optional[AsyncSTSClientConfig] = None
) -> "capo_sts.types.get_caller_identity_response.GetCallerIdentityResponse":
"""<p>Returns details about the IAM user or role whose credentials are used to call the operation.</p> <note> <p>No permissions are required to perform this operation. If an administrator attaches a policy to your identity that explicitly denies access to the <code>sts:GetCallerIdentity</code> action, you can still perform this operation. Permissions are not required because the same information is returned when access is denied. To view an example response, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_access-denied-delete-mfa">I Am Not Authorized to Perform: iam:DeleteVirtualMFADevice</a> in the <i>IAM User Guide</i>.</p> </note>
Raises:
capo_sts.errors.UnknownServiceError: The service returned an error code this client does not model.
Examples:
To get details about a calling IAM user
This example shows a request and response made with the credentials for a user named Alice in the AWS account 123456789012.
>>> await client.get_caller_identity()
To get details about a calling user federated with AssumeRole
This example shows a request and response made with temporary credentials created by AssumeRole. The name of the assumed role is my-role-name, and the RoleSessionName is set to my-role-session-name.
>>> await client.get_caller_identity()
To get details about a calling user federated with GetFederationToken
This example shows a request and response made with temporary credentials created by using GetFederationToken. The Name parameter is set to my-federated-user-name.
>>> await client.get_caller_identity()
"""
async def _handler(
req: "AsyncOperationRequest[capo_sts.types.get_caller_identity_request.GetCallerIdentityRequest]",
) -> AsyncOperationResponse[
"capo_sts.types.get_caller_identity_response.GetCallerIdentityResponse"
]:
import capo_sts._operations.aws_security_token_service_v20110615.get_caller_identity
(
output,
http_response,
) = await capo_sts._operations.aws_security_token_service_v20110615.get_caller_identity.async_get_caller_identity(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("GetCallerIdentity")
)
input_: capo_sts.types.get_caller_identity_request.GetCallerIdentityRequest = {}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|