Skip to content

get_role_credentials async

get_role_credentials(
    role_name: RoleNameType,
    account_id: AccountIdType,
    access_token: AccessTokenType,
    *,
    config_overrides: Optional[AsyncSSOClientConfig] = None,
) -> GetRoleCredentialsResponse

Returns the STS short-term credentials for a given role name that is assigned to the user.

Parameters:

  • role_name (RoleNameType) –

    The friendly name of the role that is assigned to the user.

  • account_id (AccountIdType) –

    The identifier for the AWS account that is assigned to the user.

  • access_token (AccessTokenType) –

    The token issued by the CreateToken API call. For more information, see CreateToken in the IAM Identity Center OIDC API Reference Guide.

Raises:

  • InvalidRequestException –

    Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.

  • ResourceNotFoundException –

    The specified resource doesn't exist.

  • TooManyRequestsException –

    Indicates that the request is being made too frequently and is more than what the server can handle.

  • UnauthorizedException –

    Indicates that the request is not authorized. This can happen due to an invalid access token in the request.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Source code in docs_src/capo_sso/_services/async_sso.py
async def get_role_credentials(
    self,
    role_name: "capo_sso.types.role_name_type.RoleNameType",
    account_id: "capo_sso.types.account_id_type.AccountIdType",
    access_token: "capo_sso.types.access_token_type.AccessTokenType",
    *,
    config_overrides: Optional[AsyncSSOClientConfig] = None,
) -> "capo_sso.types.get_role_credentials_response.GetRoleCredentialsResponse":
    """<p>Returns the STS short-term credentials for a given role name that is assigned to the user.</p>

    Args:
        role_name: <p>The friendly name of the role that is assigned to the user.</p>
        account_id: <p>The identifier for the AWS account that is assigned to the user.</p>
        access_token: <p>The token issued by the <code>CreateToken</code> API call. For more information, see <a href="https://docs.aws.amazon.com/singlesignon/latest/OIDCAPIReference/API_CreateToken.html">CreateToken</a> in the <i>IAM Identity Center OIDC API Reference Guide</i>.</p>

    Raises:
        capo_sso.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that a problem occurred with the input to the request. For example, a required parameter might be missing or out of range.</p>
        capo_sso.errors.resource_not_found_exception.ResourceNotFoundException: <p>The specified resource doesn't exist.</p>
        capo_sso.errors.too_many_requests_exception.TooManyRequestsException: <p>Indicates that the request is being made too frequently and is more than what the server can handle.</p>
        capo_sso.errors.unauthorized_exception.UnauthorizedException: <p>Indicates that the request is not authorized. This can happen due to an invalid access token in the request.</p>
        capo_sso.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sso.types.get_role_credentials_request.GetRoleCredentialsRequest]",
    ) -> AsyncOperationResponse[
        "capo_sso.types.get_role_credentials_response.GetRoleCredentialsResponse"
    ]:
        import capo_sso._operations.swb_portal_service.get_role_credentials

        (
            output,
            http_response,
        ) = await capo_sso._operations.swb_portal_service.get_role_credentials.async_get_role_credentials(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sso.types.get_role_credentials_request.GetRoleCredentialsRequest",
    ) -> dict[str, Any]:
        import capo_sso.types.get_role_credentials_request

        return capo_sso.types.get_role_credentials_request.redact_sensitive(input_)

    def _redact_output(
        output: "capo_sso.types.get_role_credentials_response.GetRoleCredentialsResponse",
    ) -> dict[str, Any]:
        import capo_sso.types.get_role_credentials_response

        return capo_sso.types.get_role_credentials_response.redact_sensitive(output)

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "GetRoleCredentials",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_sso.types.get_role_credentials_request.GetRoleCredentialsRequest = {
        "role_name": role_name,
        "account_id": account_id,
        "access_token": access_token,
    }

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output