Skip to content

get_open_id_token_for_developer_identity async

get_open_id_token_for_developer_identity(
    identity_pool_id: IdentityPoolId,
    logins: LoginsMap,
    *,
    config_overrides: Optional[AsyncCognitoIdentityClientConfig] = None,
    identity_id: Optional[IdentityId] = None,
    principal_tags: Optional[PrincipalTags] = None,
    token_duration: Optional[TokenDuration] = None,
) -> GetOpenIdTokenForDeveloperIdentityResponse

Registers (or retrieves) a Cognito IdentityId and an OpenID Connect token for a user authenticated by your backend authentication process. Supplying multiple logins will create an implicit linked account. You can only specify one developer provider as part of the Logins map, which is linked to the identity pool. The developer provider is the "domain" by which Cognito will refer to your users.

You can use GetOpenIdTokenForDeveloperIdentity to create a new identity and to link new logins (that is, user credentials issued by a public provider or developer provider) to an existing identity. When you want to create a new identity, the IdentityId should be null. When you want to associate a new login with an existing authenticated/unauthenticated identity, you can do so by providing the existing IdentityId. This API will create the identity in the specified IdentityPoolId.

You must use Amazon Web Services developer credentials to call this operation.

Parameters:

  • identity_pool_id (IdentityPoolId) –

    An identity pool ID in the format REGION:GUID.

  • identity_id (Optional[IdentityId], default: None ) –

    A unique identifier in the format REGION:GUID.

  • logins (LoginsMap) –

    A set of optional name-value pairs that map provider names to provider tokens. Each name-value pair represents a user from a public provider or developer provider. If the user is from a developer provider, the name-value pair will follow the syntax "developer_provider_name": "developer_user_identifier". The developer provider is the "domain" by which Cognito will refer to your users; you provided this domain while creating/updating the identity pool. The developer user identifier is an identifier from your backend that uniquely identifies a user. When you create an identity pool, you can specify the supported logins.

  • principal_tags (Optional[PrincipalTags], default: None ) –

    Use this operation to configure attribute mappings for custom providers.

  • token_duration (Optional[TokenDuration], default: None ) –

    The expiration time of the token, in seconds. You can specify a custom expiration time for the token so that you can cache it. If you don't provide an expiration time, the token is valid for 15 minutes. You can exchange the token with Amazon STS for temporary Amazon Web Services credentials, which are valid for a maximum of one hour. The maximum token duration you can set is 24 hours. You should take care in setting the expiration time for a token, as there are significant security implications: an attacker could use a leaked token to access your Amazon Web Services resources for the token's duration.

    Please provide for a small grace period, usually no more than 5 minutes, to account for clock skew.

Raises:

Source code in docs_src/capo_cognito_identity/_services/async_cognito_identity.py
async def get_open_id_token_for_developer_identity(
    self,
    identity_pool_id: "capo_cognito_identity.types.identity_pool_id.IdentityPoolId",
    logins: "capo_cognito_identity.types.logins_map.LoginsMap",
    *,
    config_overrides: Optional[AsyncCognitoIdentityClientConfig] = None,
    identity_id: Optional[
        "capo_cognito_identity.types.identity_id.IdentityId"
    ] = None,
    principal_tags: Optional[
        "capo_cognito_identity.types.principal_tags.PrincipalTags"
    ] = None,
    token_duration: Optional[
        "capo_cognito_identity.types.token_duration.TokenDuration"
    ] = None,
) -> "capo_cognito_identity.types.get_open_id_token_for_developer_identity_response.GetOpenIdTokenForDeveloperIdentityResponse":
    """<p>Registers (or retrieves) a Cognito <code>IdentityId</code> and an OpenID Connect token for a user authenticated by your backend authentication process. Supplying multiple logins will create an implicit linked account. You can only specify one developer provider as part of the <code>Logins</code> map, which is linked to the identity pool. The developer provider is the "domain" by which Cognito will refer to your users.</p> <p>You can use <code>GetOpenIdTokenForDeveloperIdentity</code> to create a new identity and to link new logins (that is, user credentials issued by a public provider or developer provider) to an existing identity. When you want to create a new identity, the <code>IdentityId</code> should be null. When you want to associate a new login with an existing authenticated/unauthenticated identity, you can do so by providing the existing <code>IdentityId</code>. This API will create the identity in the specified <code>IdentityPoolId</code>.</p> <p>You must use Amazon Web Services developer credentials to call this operation.</p>

    Args:
        identity_pool_id: <p>An identity pool ID in the format REGION:GUID.</p>
        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. Each name-value pair represents a user from a public provider or developer provider. If the user is from a developer provider, the name-value pair will follow the syntax <code>"developer_provider_name": "developer_user_identifier"</code>. The developer provider is the "domain" by which Cognito will refer to your users; you provided this domain while creating/updating the identity pool. The developer user identifier is an identifier from your backend that uniquely identifies a user. When you create an identity pool, you can specify the supported logins.</p>
        principal_tags: <p>Use this operation to configure attribute mappings for custom providers. </p>
        token_duration: <p>The expiration time of the token, in seconds. You can specify a custom expiration time for the token so that you can cache it. If you don't provide an expiration time, the token is valid for 15 minutes. You can exchange the token with Amazon STS for temporary Amazon Web Services credentials, which are valid for a maximum of one hour. The maximum token duration you can set is 24 hours. You should take care in setting the expiration time for a token, as there are significant security implications: an attacker could use a leaked token to access your Amazon Web Services resources for the token's duration.</p> <note> <p>Please provide for a small grace period, usually no more than 5 minutes, to account for clock skew.</p> </note>

    Raises:
        capo_cognito_identity.errors.developer_user_already_registered_exception.DeveloperUserAlreadyRegisteredException: <p>The provided developer user identifier is already registered with Cognito under a different identity ID.</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_for_developer_identity_input.GetOpenIdTokenForDeveloperIdentityInput]",
    ) -> AsyncOperationResponse[
        "capo_cognito_identity.types.get_open_id_token_for_developer_identity_response.GetOpenIdTokenForDeveloperIdentityResponse"
    ]:
        import capo_cognito_identity._operations.aws_cognito_identity_service.get_open_id_token_for_developer_identity

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

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

        return capo_cognito_identity.types.get_open_id_token_for_developer_identity_input.redact_sensitive(
            input_
        )

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

        return capo_cognito_identity.types.get_open_id_token_for_developer_identity_response.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging(
            "GetOpenIdTokenForDeveloperIdentity",
            redact_input=_redact_input,
            redact_output=_redact_output,
        ),
    )
    input_: capo_cognito_identity.types.get_open_id_token_for_developer_identity_input.GetOpenIdTokenForDeveloperIdentityInput = {
        "identity_pool_id": identity_pool_id,
        "logins": logins,
    }
    if identity_id is not None:
        input_["identity_id"] = identity_id
    if principal_tags is not None:
        input_["principal_tags"] = principal_tags
    if token_duration is not None:
        input_["token_duration"] = token_duration

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