Skip to content

create_token async

create_token(
    license_arn: Arn,
    client_token: ClientToken,
    *,
    config_overrides: Optional[AsyncLicenseManagerClientConfig] = None,
    role_arns: Optional[ArnList] = None,
    expiration_in_days: Optional[Integer] = None,
    token_properties: Optional[MaxSize3StringList] = None,
) -> CreateTokenResponse

Creates a long-lived token.

A refresh token is a JWT token used to get an access token. With an access token, you can call AssumeRoleWithWebIdentity to get role credentials that you can use to call License Manager to manage the specified license.

Parameters:

  • license_arn (Arn) –

    Amazon Resource Name (ARN) of the license. The ARN is mapped to the aud claim of the JWT token.

  • role_arns (Optional[ArnList], default: None ) –

    Amazon Resource Name (ARN) of the IAM roles to embed in the token. License Manager does not check whether the roles are in use.

  • expiration_in_days (Optional[Integer], default: None ) –

    Token expiration, in days, counted from token creation. The default is 365 days.

  • token_properties (Optional[MaxSize3StringList], default: None ) –

    Data specified by the caller to be included in the JWT token. The data is mapped to the amr claim of the JWT token.

  • client_token (ClientToken) –

    Idempotency token, valid for 10 minutes.

Raises:

Source code in docs_src/capo_license_manager/_services/async_license_manager.py
async def create_token(
    self,
    license_arn: "capo_license_manager.types.arn.Arn",
    client_token: "capo_license_manager.types.client_token.ClientToken",
    *,
    config_overrides: Optional[AsyncLicenseManagerClientConfig] = None,
    role_arns: Optional["capo_license_manager.types.arn_list.ArnList"] = None,
    expiration_in_days: Optional[
        "capo_license_manager.types.integer.Integer"
    ] = None,
    token_properties: Optional[
        "capo_license_manager.types.max_size3_string_list.MaxSize3StringList"
    ] = None,
) -> "capo_license_manager.types.create_token_response.CreateTokenResponse":
    """<p>Creates a long-lived token.</p> <p>A refresh token is a JWT token used to get an access token. With an access token, you can call AssumeRoleWithWebIdentity to get role credentials that you can use to call License Manager to manage the specified license.</p>

    Args:
        license_arn: <p>Amazon Resource Name (ARN) of the license. The ARN is mapped to the aud claim of the JWT token.</p>
        role_arns: <p>Amazon Resource Name (ARN) of the IAM roles to embed in the token. License Manager does not check whether the roles are in use.</p>
        expiration_in_days: <p>Token expiration, in days, counted from token creation. The default is 365 days.</p>
        token_properties: <p>Data specified by the caller to be included in the JWT token. The data is mapped to the amr claim of the JWT token.</p>
        client_token: <p>Idempotency token, valid for 10 minutes.</p>

    Raises:
        capo_license_manager.errors.access_denied_exception.AccessDeniedException: <p>Access to resource denied.</p>
        capo_license_manager.errors.authorization_exception.AuthorizationException: <p>The Amazon Web Services user account does not have permission to perform the action. Check the IAM policy associated with this account.</p>
        capo_license_manager.errors.rate_limit_exceeded_exception.RateLimitExceededException: <p>Too many requests have been submitted. Try again after a brief wait.</p>
        capo_license_manager.errors.redirect_exception.RedirectException: <p>This is not the correct Region for the resource. Try again.</p>
        capo_license_manager.errors.resource_limit_exceeded_exception.ResourceLimitExceededException: <p>Your resource limits have been exceeded.</p>
        capo_license_manager.errors.resource_not_found_exception.ResourceNotFoundException: <p>The resource cannot be found.</p>
        capo_license_manager.errors.server_internal_exception.ServerInternalException: <p>The server experienced an internal error. Try again.</p>
        capo_license_manager.errors.validation_exception.ValidationException: <p>The provided input is not valid. Try your request again.</p>
        capo_license_manager.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_license_manager.types.create_token_request.CreateTokenRequest]",
    ) -> AsyncOperationResponse[
        "capo_license_manager.types.create_token_response.CreateTokenResponse"
    ]:
        import capo_license_manager._operations.aws_license_manager.create_token

        (
            output,
            http_response,
        ) = await capo_license_manager._operations.aws_license_manager.create_token.async_create_token(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateToken")
    )
    input_: capo_license_manager.types.create_token_request.CreateTokenRequest = {
        "license_arn": license_arn,
        "client_token": client_token,
    }
    if role_arns is not None:
        input_["role_arns"] = role_arns
    if expiration_in_days is not None:
        input_["expiration_in_days"] = expiration_in_days
    if token_properties is not None:
        input_["token_properties"] = token_properties

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