Skip to content

get_open_id_token async

get_open_id_token(
    identity_id: IdentityId,
    *,
    config_overrides: Optional[AsyncCognitoIdentityClientConfig] = None,
    logins: Optional[LoginsMap] = None,
) -> GetOpenIdTokenResponse

Gets an OpenID token, using a known Cognito ID. This known Cognito ID is returned by GetId. You can optionally add additional logins for the identity. Supplying multiple logins creates an implicit link.

The OpenID token is valid for 10 minutes.

This is a public API. You do not need any credentials to call this API.

Parameters:

  • identity_id (IdentityId) –

    A unique identifier in the format REGION:GUID.

  • logins (Optional[LoginsMap], default: None ) –

    A set of optional name-value pairs that map provider names to provider tokens. When using graph.facebook.com and www.amazon.com, supply the access_token returned from the provider's authflow. For accounts.google.com, an Amazon Cognito user pool provider, or any other OpenID Connect provider, always include the id_token.

Raises:

Source code in docs_src/capo_cognito_identity/_services/async_cognito_identity.py
async def get_open_id_token(
    self,
    identity_id: "capo_cognito_identity.types.identity_id.IdentityId",
    *,
    config_overrides: Optional[AsyncCognitoIdentityClientConfig] = None,
    logins: Optional["capo_cognito_identity.types.logins_map.LoginsMap"] = None,
) -> (
    "capo_cognito_identity.types.get_open_id_token_response.GetOpenIdTokenResponse"
):
    """<p>Gets an OpenID token, using a known Cognito ID. This known Cognito ID is returned by <a>GetId</a>. You can optionally add additional logins for the identity. Supplying multiple logins creates an implicit link.</p> <p>The OpenID token is valid for 10 minutes.</p> <p>This is a public API. You do not need any credentials to call this API.</p>

    Args:
        identity_id: <p>A unique identifier in the format REGION:GUID.</p>
        logins: <p>A set of optional name-value pairs that map provider names to provider tokens. When using graph.facebook.com and www.amazon.com, supply the access_token returned from the provider's authflow. For accounts.google.com, an Amazon Cognito user pool provider, or any other OpenID Connect provider, always include the <code>id_token</code>.</p>

    Raises:
        capo_cognito_identity.errors.external_service_exception.ExternalServiceException: <p>An exception thrown when a dependent service such as Facebook or Twitter is not responding</p>
        capo_cognito_identity.errors.internal_error_exception.InternalErrorException: <p>Thrown when the service encounters an error during processing the request.</p>
        capo_cognito_identity.errors.invalid_parameter_exception.InvalidParameterException: <p>Thrown for missing or bad input parameter(s).</p>
        capo_cognito_identity.errors.not_authorized_exception.NotAuthorizedException: <p>Thrown when a user is not authorized to access the requested resource.</p>
        capo_cognito_identity.errors.resource_conflict_exception.ResourceConflictException: <p>Thrown when a user tries to use a login which is already linked to another account.</p>
        capo_cognito_identity.errors.resource_not_found_exception.ResourceNotFoundException: <p>Thrown when the requested resource (for example, a dataset or record) does not exist.</p>
        capo_cognito_identity.errors.too_many_requests_exception.TooManyRequestsException: <p>Thrown when a request is throttled.</p>
        capo_cognito_identity.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cognito_identity.types.get_open_id_token_input.GetOpenIdTokenInput]",
    ) -> AsyncOperationResponse[
        "capo_cognito_identity.types.get_open_id_token_response.GetOpenIdTokenResponse"
    ]:
        import capo_cognito_identity._operations.aws_cognito_identity_service.get_open_id_token

        (
            output,
            http_response,
        ) = await capo_cognito_identity._operations.aws_cognito_identity_service.get_open_id_token.async_get_open_id_token(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_cognito_identity.types.get_open_id_token_input.GetOpenIdTokenInput",
    ) -> dict[str, Any]:
        import capo_cognito_identity.types.get_open_id_token_input

        return capo_cognito_identity.types.get_open_id_token_input.redact_sensitive(
            input_
        )

    def _redact_output(
        output: "capo_cognito_identity.types.get_open_id_token_response.GetOpenIdTokenResponse",
    ) -> dict[str, Any]:
        import capo_cognito_identity.types.get_open_id_token_response

        return (
            capo_cognito_identity.types.get_open_id_token_response.redact_sensitive(
                output
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "GetOpenIdToken",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cognito_identity.types.get_open_id_token_input.GetOpenIdTokenInput = {
        "identity_id": identity_id
    }
    if logins is not None:
        input_["logins"] = logins

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