Skip to content

start_device_authorization async

start_device_authorization(
    client_id: ClientId,
    client_secret: ClientSecret,
    start_url: URI,
    *,
    config_overrides: Optional[AsyncSSOOIDCClientConfig] = None,
) -> StartDeviceAuthorizationResponse

Initiates device authorization by requesting a pair of verification codes from the authorization service.

Parameters:

  • client_id (ClientId) –

    The unique identifier string for the client that is registered with IAM Identity Center. This value should come from the persisted result of the RegisterClient API operation.

  • client_secret (ClientSecret) –

    A secret string that is generated for the client. This value should come from the persisted result of the RegisterClient API operation.

  • start_url (URI) –

    The URL for the Amazon Web Services access portal. For more information, see Using the Amazon Web Services access portal in the IAM Identity Center User Guide.

Raises:

  • InternalServerException –

    Indicates that an error from the service occurred while trying to process a request.

  • InvalidClientException –

    Indicates that the clientId or clientSecret in the request is invalid. For example, this can occur when a client sends an incorrect clientId or an expired clientSecret.

  • InvalidRequestException –

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

  • SlowDownException –

    Indicates that the client is making the request too frequently and is more than the service can handle.

  • UnauthorizedClientException –

    Indicates that the client is not currently authorized to make the request. This can happen when a clientId is not issued for a public client.

  • UnknownServiceError –

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

Examples:

Call OAuth/OIDC /start-device-authorization endpoint

>>> await client.start_device_authorization(client_id='_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID', client_secret='VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0', start_url='https://identitycenter.amazonaws.com/ssoins-111111111111')
Source code in docs_src/capo_sso_oidc/_services/async_ssooidc.py
async def start_device_authorization(
    self,
    client_id: "capo_sso_oidc.types.client_id.ClientId",
    client_secret: "capo_sso_oidc.types.client_secret.ClientSecret",
    start_url: "capo_sso_oidc.types.uri.URI",
    *,
    config_overrides: Optional[AsyncSSOOIDCClientConfig] = None,
) -> "capo_sso_oidc.types.start_device_authorization_response.StartDeviceAuthorizationResponse":
    """<p>Initiates device authorization by requesting a pair of verification codes from the authorization service.</p>

    Args:
        client_id: <p>The unique identifier string for the client that is registered with IAM Identity Center. This value should come from the persisted result of the <a>RegisterClient</a> API operation.</p>
        client_secret: <p>A secret string that is generated for the client. This value should come from the persisted result of the <a>RegisterClient</a> API operation.</p>
        start_url: <p>The URL for the Amazon Web Services access portal. For more information, see <a href="https://docs.aws.amazon.com/singlesignon/latest/userguide/using-the-portal.html">Using the Amazon Web Services access portal</a> in the <i>IAM Identity Center User Guide</i>.</p>

    Raises:
        capo_sso_oidc.errors.internal_server_exception.InternalServerException: <p>Indicates that an error from the service occurred while trying to process a request.</p>
        capo_sso_oidc.errors.invalid_client_exception.InvalidClientException: <p>Indicates that the <code>clientId</code> or <code>clientSecret</code> in the request is invalid. For example, this can occur when a client sends an incorrect <code>clientId</code> or an expired <code>clientSecret</code>.</p>
        capo_sso_oidc.errors.invalid_request_exception.InvalidRequestException: <p>Indicates that something is wrong with the input to the request. For example, a required parameter might be missing or out of range.</p>
        capo_sso_oidc.errors.slow_down_exception.SlowDownException: <p>Indicates that the client is making the request too frequently and is more than the service can handle. </p>
        capo_sso_oidc.errors.unauthorized_client_exception.UnauthorizedClientException: <p>Indicates that the client is not currently authorized to make the request. This can happen when a <code>clientId</code> is not issued for a public client.</p>
        capo_sso_oidc.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Call OAuth/OIDC /start-device-authorization endpoint

        >>> await client.start_device_authorization(client_id='_yzkThXVzLWVhc3QtMQEXAMPLECLIENTID', client_secret='VERYLONGSECRETeyJraWQiOiJrZXktMTU2NDAyODA5OSIsImFsZyI6IkhTMzg0In0', start_url='https://identitycenter.amazonaws.com/ssoins-111111111111')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_sso_oidc.types.start_device_authorization_request.StartDeviceAuthorizationRequest]",
    ) -> AsyncOperationResponse[
        "capo_sso_oidc.types.start_device_authorization_response.StartDeviceAuthorizationResponse"
    ]:
        import capo_sso_oidc._operations.awsssooidc_service.start_device_authorization

        (
            output,
            http_response,
        ) = await capo_sso_oidc._operations.awsssooidc_service.start_device_authorization.async_start_device_authorization(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    def _redact_input(
        input_: "capo_sso_oidc.types.start_device_authorization_request.StartDeviceAuthorizationRequest",
    ) -> dict[str, Any]:
        import capo_sso_oidc.types.start_device_authorization_request

        return (
            capo_sso_oidc.types.start_device_authorization_request.redact_sensitive(
                input_
            )
        )

    interceptors_, options_ = self.operation_options(
        config_overrides,
        OperationLogging("StartDeviceAuthorization", redact_input=_redact_input),
    )
    input_: capo_sso_oidc.types.start_device_authorization_request.StartDeviceAuthorizationRequest = {
        "client_id": client_id,
        "client_secret": client_secret,
        "start_url": start_url,
    }

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