Skip to content

create_one_time_deep_link_code async

create_one_time_deep_link_code(
    domain_id: DomainId,
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    ttl_seconds: Optional[int] = None,
    redirect_url: Optional[str] = None,
) -> CreateOneTimeDeepLinkCodeOutput

Generates a one-time code for deep-link authentication. Direct the user's browser to the returned deepLinkUrl before it expires. The code is exchanged for an authenticated, domain-scoped session and can be used only once.

Parameters:

  • domain_id (DomainId) –

    The ID of the domain to generate the code for.

  • ttl_seconds (Optional[int], default: None ) –

    How long the code remains valid, in seconds. Defaults to 300.

  • redirect_url (Optional[str], default: None ) –

    The URL to redirect to after the deep-link code is used. Must be an HTTPS URL in the domain with a path of /auth/callback, and cannot include a query string or fragment. If omitted, no redirect is applied.

Raises:

Examples:

Create a one-time deep-link code The following example creates a one-time deep-link code for a domain that remains valid for 300 seconds and, once used, redirects the browser to the domain's /auth/callback path. Direct the user's browser to the returned deepLinkUrl before it expires; the code can be used only once. Payloads are shown as JSON; on the wire they are CBOR-encoded.

>>> await client.create_one_time_deep_link_code(domain_id='d-1a2b3c4d5e', ttl_seconds=300, redirect_url='https://d-1a2b3c4d5e.cloudwatch-omni.global.app.aws/auth/callback')
Source code in docs_src/capo_cloudwatchomni/_services/async_cloud_watch_omni.py
async def create_one_time_deep_link_code(
    self,
    domain_id: "capo_cloudwatchomni.types.domain_id.DomainId",
    *,
    config_overrides: Optional[AsyncCloudWatchOmniClientConfig] = None,
    ttl_seconds: Optional[int] = None,
    redirect_url: Optional[str] = None,
) -> "capo_cloudwatchomni.types.create_one_time_deep_link_code_output.CreateOneTimeDeepLinkCodeOutput":
    """Generates a one-time code for deep-link authentication. Direct the user's browser to the returned deepLinkUrl before it expires. The code is exchanged for an authenticated, domain-scoped session and can be used only once.

    Args:
        domain_id: The ID of the domain to generate the code for.
        ttl_seconds: How long the code remains valid, in seconds. Defaults to 300.
        redirect_url: The URL to redirect to after the deep-link code is used. Must be an HTTPS URL in the domain with a path of /auth/callback, and cannot include a query string or fragment. If omitted, no redirect is applied.

    Raises:
        capo_cloudwatchomni.errors.access_denied_exception.AccessDeniedException: The caller is not authorized to perform this action.
        capo_cloudwatchomni.errors.internal_server_exception.InternalServerException: An unexpected error occurred while processing the request.
        capo_cloudwatchomni.errors.resource_not_found_exception.ResourceNotFoundException: The specified resource does not exist.
        capo_cloudwatchomni.errors.throttling_exception.ThrottlingException: The request was throttled due to exceeding the allowed request rate.
        capo_cloudwatchomni.errors.validation_exception.ValidationException: A parameter is specified incorrectly.
        capo_cloudwatchomni.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create a one-time deep-link code
        The following example creates a one-time deep-link code for a domain that remains valid for 300 seconds and, once used, redirects the browser to the domain's /auth/callback path. Direct the user's browser to the returned deepLinkUrl before it expires; the code can be used only once. Payloads are shown as JSON; on the wire they are CBOR-encoded.

        >>> await client.create_one_time_deep_link_code(domain_id='d-1a2b3c4d5e', ttl_seconds=300, redirect_url='https://d-1a2b3c4d5e.cloudwatch-omni.global.app.aws/auth/callback')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_cloudwatchomni.types.create_one_time_deep_link_code_input.CreateOneTimeDeepLinkCodeInput]",
    ) -> AsyncOperationResponse[
        "capo_cloudwatchomni.types.create_one_time_deep_link_code_output.CreateOneTimeDeepLinkCodeOutput"
    ]:
        import capo_cloudwatchomni._operations.cloud_watch_omni_frontend.create_one_time_deep_link_code

        (
            output,
            http_response,
        ) = await capo_cloudwatchomni._operations.cloud_watch_omni_frontend.create_one_time_deep_link_code.async_create_one_time_deep_link_code(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_output(
        output: "capo_cloudwatchomni.types.create_one_time_deep_link_code_output.CreateOneTimeDeepLinkCodeOutput",
    ) -> dict[str, Any]:
        import capo_cloudwatchomni.types.create_one_time_deep_link_code_output

        return capo_cloudwatchomni.types.create_one_time_deep_link_code_output.redact_sensitive(
            output
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("CreateOneTimeDeepLinkCode", redact_output=_redact_output),
    )
    input_: capo_cloudwatchomni.types.create_one_time_deep_link_code_input.CreateOneTimeDeepLinkCodeInput = {
        "domain_id": domain_id
    }
    if ttl_seconds is not None:
        input_["ttl_seconds"] = ttl_seconds
    if redirect_url is not None:
        input_["redirect_url"] = redirect_url

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