﻿---
title: License
description: The license state of this device, or of this program under an Application license, and the calls that refresh it, sign in to a subscription, and activate and deactivate a license.
url: https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/
---

# License – Python API Reference – Deformable v0.8.0

The license: its state, and the calls that refresh it, sign in to a subscription, and activate and deactivate a license. Nothing ever refuses to run: without a subscription or a license, Free runs, and a scene simulates at most 2,500 tetrahedrons. Three ways lift the limit: the Standalone subscription the person signs in to, the Standalone license of this device and user, and the Application license that a program activates for itself. A license failure's message is written to show the user as it is, such as "Free: this would simulate 3,000 tetrahedrons; the limit is 2,500 per scene".

[`license.start_sign_in`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-start_sign_in) starts a sign-in to a Standalone subscription: it gives a [`SignIn`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#signin) whose code the person approves in their browser, and [`license.wait_for_sign_in`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-wait_for_sign_in) waits for that approval, then takes this device's seat. [`license.take_over`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-take_over) moves the seat to this device from the one using it, and [`license.sign_out`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-sign_out) frees the seat and forgets the sign-in. [`license.activate`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-activate) takes both kinds of key. A Standalone key is activated online once and stays on the device; the library keeps one Standalone state per device and user, shared by every program that loads it: the plugins and the SDKs. An Application key is checked offline and holds for the process only, so a program activates it at every start, before any other engine call; with it, the other calls contact nothing, and a plugin host refuses it. [`license.status`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-status) never contacts the licensing service and is cheap enough to call on every redraw. The other calls wait on the network for at most their timeout, so a host with an interface calls them off its interface thread. [`license.set_online_access`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) keeps a process off the network when its user asked for that.

- The Standalone subscription runs on 1 device. The person signs in with their account in the browser ([`start_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-start_sign_in), then [`wait_for_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-wait_for_sign_in) until it gives a state); the sign-in and the lease our licensing service signs for this device belong to this device and user, and every program that loads the library shares them. [`refresh()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-refresh) renews it, [`take_over()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-take_over) uses it on this device instead of another, and [`sign_out()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-sign_out) frees the seat. The lease renews on its own while the engine runs, and a device may stay offline up to 1 day.
- The Standalone license runs on 1 device per seat. Its key and the lease our licensing service signs for this device belong to this device and user, and every program that loads the library shares them; [`activate()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-activate), [`refresh()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-refresh) and [`deactivate()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-deactivate) activate, renew and deactivate it. The lease renews on its own while the engine runs, and a device may stay offline up to 7 days. A device holds a subscription or a license, not both.
- The Application license is a company's, for one app it ships. Its key is checked offline and licenses the program that activates it, on any device, for as long as it runs: nothing is stored or sent, so the app activates its key at every start, as its first Deformable call, before status and refresh, and its users need nothing. The plugins refuse an Application key.

## LicenseState

**Enum** · `deformable.LicenseState`

```python
class LicenseState(enum.IntEnum):
    FREE = 0
    STANDALONE_SUBSCRIPTION = 1
    SUBSCRIPTION_NEEDS_ONLINE = 2
    SUBSCRIPTION_NO_SEAT = 3
    NO_SUBSCRIPTION = 4
    SIGN_IN_ENDED = 5
    STANDALONE_LICENSE = 6
    LICENSE_NEEDS_ONLINE = 7
    DEVELOPMENT = 8
    APPLICATION_TRIAL = 9
    APPLICATION_TRIAL_ENDED = 10
    APPLICATION_LICENSE = 11
```

The license state of this program, as [`LicenseStatus.state`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus) reports it: its Application license, or else the Standalone subscription, the Standalone license or Free of this device and user, which every program that loads the library shares.

**Values**

- `FREE` (`0`): No license key and no sign-in: Free, at most [`LicenseStatus.tetrahedron_limit`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus) (2,500) tetrahedrons per scene.
- `STANDALONE_SUBSCRIPTION` (`1`): Signed in to a Standalone subscription, and this device holds a seat whose lease licenses it; no limit.
- `SUBSCRIPTION_NEEDS_ONLINE` (`2`): Signed in, but no subscription lease licenses this device now: it lapsed, this device's clock leaves it untrusted, or the first seat could not be taken. Free runs until the next renewal online.
- `SUBSCRIPTION_NO_SEAT` (`3`): Signed in, but this device holds no seat: another device took it over, it was removed, or every seat is in use. Free runs; a host offers to use the subscription here instead ([`take_over()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-take_over)).
- `NO_SUBSCRIPTION` (`4`): Signed in, but the account has no active Standalone subscription: Free runs.
- `SIGN_IN_ENDED` (`5`): The licensing service no longer accepts the stored sign-in: Free runs until the person signs in again.
- `STANDALONE_LICENSE` (`6`): A Standalone license key with a lease that licenses this device; no limit.
- `LICENSE_NEEDS_ONLINE` (`7`): A Standalone license key whose lease ran out, or that this device's clock leaves untrusted: Free runs until the next renewal online.
- `DEVELOPMENT` (`8`): A development build of the library: licensing is off, no limit, and nothing contacts the licensing service. It is not the Application license.
- `APPLICATION_TRIAL` (`9`): An Application trial key runs in this program: no limit, until the key ends.
- `APPLICATION_TRIAL_ENDED` (`10`): The Application trial key of this program ended: Free runs.
- `APPLICATION_LICENSE` (`11`): A full Application license key runs in this program; no limit.

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `DeformableLicenseState`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformablelicensestate) · [Rust `LicenseState`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#licensestate)

## LicenseStatus

**Data class** · `deformable.LicenseStatus`

```python
@dataclasses.dataclass(frozen=True)
class LicenseStatus:
    state: LicenseState | int
    days_left: int
    tetrahedron_limit: int | None
    has_license_key: bool
    signed_in: bool
    account: str | None
    message: str
```

The license state as a status line shows it.

**Fields**

- `state` ([`LicenseState`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate) or `int`): Which license state the program is in, which the other fields detail; a plain int for a state a newer library reports that this package does not know yet.
- `days_left` (`int`): In [`APPLICATION_TRIAL`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-application_trial), the whole days until the trial key ends counting the current day, 30 down to 1 for a 30-day key; 0 in any other state.
- `tetrahedron_limit` (`int` or `None`): The most tetrahedrons one scene simulates: 2,500 under Free and every state that falls back to it; None when there is no limit.
- `has_license_key` (`bool`): A Standalone license key is stored on this device, so a host offers Deactivate rather than Activate; never under an Application license.
- `signed_in` (`bool`): A Standalone subscription sign-in is stored on this device, so a host offers Sign Out; in [`SIGN_IN_ENDED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-sign_in_ended) it offers Sign In again too. Never under an Application license.
- `account` (`str` or `None`): The email of the signed-in account; None when not signed in, when it could not be read yet, under an Application license and in a development build.
- `message` (`str`): The status line: "Free: up to 2,500 tetrahedrons per scene", "Standalone subscription", "Standalone license", "Application trial: 30 days left", "Application license: Acme Inc.", ... A device or company name in it is cut to fit.

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `DeformableLicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformablelicensestatus) · [Rust `LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#licensestatus)

## SignIn

**Data class** · `deformable.SignIn`

```python
@dataclasses.dataclass(frozen=True)
class SignIn:
    user_code: str
    verification_url: str
    expires_in: float
```

A sign-in to a Standalone subscription in progress, as [`start_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-start_sign_in) gives it: what the host shows, and how long the code lasts.

**Fields**

- `user_code` (`str`): The code to approve in the browser, such as "ABCD-EFGH".
- `verification_url` (`str`): The page that approves it with the code filled in; the host opens it in the browser.
- `expires_in` (`float`): How long the code lasts from now, in seconds.

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `DeformableSignIn`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformablesignin) · [Rust `SignIn`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#signin)

## license.status

**Function** · `deformable.license.status`

```python
def status() -> LicenseStatus
```

The license state of this program: its Application license, or else the Standalone subscription, the Standalone license or Free of this device and user. It never contacts the licensing service and never waits on the network: it reads the per-user license store at most once every 2 seconds, so it is cheap enough to call on every redraw.

**Raises**

Only the errors every call can raise, which the [conventions](https://help.tangerina.io/deformable/v0.8.0/api-references/python/overview/#conventions) describe.

**Example**

```python
status = deformable.license.status()
if status.tetrahedron_limit is not None:
    print(status.message)
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_status`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_status) · [Rust `status`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#status)

## license.DEFAULT_TIMEOUT

**Constant** · `deformable.license.DEFAULT_TIMEOUT`

```python
DEFAULT_TIMEOUT = 15.0
```

How long the calls that contact the licensing service wait for it by default, in seconds. The library counts anything above 60 seconds as 60 seconds.

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [Rust `DEFAULT_TIMEOUT`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#default_timeout)

## license.refresh

**Function** · `deformable.license.refresh`

```python
def refresh(timeout: float = DEFAULT_TIMEOUT) -> LicenseStatus
```

Renews the stored Standalone key's lease when it no longer licenses this device, or when it is 6 hours old or ends within a day and no contact ran in the last 5 minutes, waiting at most `timeout` seconds. With a Standalone subscription instead, renews its lease when no contact ran in the last 5 minutes, so a seat taken over or removed, or a subscription that ended, shows at once; without a current lease or a seat, renews it or takes a free seat whatever the last contact was, never one another device holds. Under Free, after the sign-in ended, and under an Application license, nothing is sent and it gives the state as it is. The library renews a lease on its own while the engine runs, so a host calls this when the program starts and when its user asks.

It waits on the network with the global interpreter lock released, so a host with an interface runs it off its main thread. Contacts run one at a time per process: a second caller waits for the first.

**Parameters**

- `timeout` (`float`): How long to wait for the service, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds.

**Returns**

[`LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus): The license state after the call. After a failure, [`status()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-status) gives the state to show.

**Raises**

[`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror) with one of these statuses:

- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): The service could not be reached or did not answer, its answer did not verify or this device's clock contradicts it, or [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact. The lease is kept until it runs out.
- [`LICENSE_KEY_REJECTED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_key_rejected): The service no longer accepts the key: it was revoked or refunded, or this device was removed. The license is then forgotten at once and Free runs.
- [`LICENSE_SIGN_IN_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_sign_in_failed): The service could not read the request. A subscription that gives this device no seat is no error: the state says it.
- [`LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_storage_failed): The per-user license store could not be written; the message names its folder.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

`ValueError` when `timeout` is NaN, 0 or less.

**Example**

```python
try:
    status = deformable.license.refresh()
except deformable.LicenseError as error:
    print(error.message)
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_refresh`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_refresh) · [Rust `refresh`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#refresh)

## license.start_sign_in

**Function** · `deformable.license.start_sign_in`

```python
def start_sign_in(timeout: float = DEFAULT_TIMEOUT) -> SignIn
```

Starts a sign-in to a Standalone subscription in the browser, waiting at most `timeout` seconds for the licensing service: the host shows `user_code` and opens `verification_url`, where the person approves it, then calls [`wait_for_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-wait_for_sign_in) until it gives a state. Starting again replaces the sign-in this program started before. It waits on the network with the global interpreter lock released, so a host with an interface runs it off its main thread.

**Parameters**

- `timeout` (`float`): How long to wait for the service, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds.

**Returns**

[`SignIn`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#signin): The code to show, the page to open and how long the code lasts.

**Raises**

[`DeformableError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#deformableerror) with one of these statuses; the license ones raise its subclass [`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror):

- [`INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-invalid_argument): A Standalone key is stored on this device ("Deactivate the current license first"), a sign-in is stored, except in [`SIGN_IN_ENDED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-sign_in_ended) ("Sign out of the Standalone subscription first"), or the program uses an Application license.
- [`LICENSE_SIGN_IN_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_sign_in_failed): This version of the library may not sign in, or the service could not read the request.
- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): The service could not be reached or did not answer, [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact, or licensing is off in a development build of the library.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

`ValueError` when `timeout` is NaN, 0 or less.

**Example**

```python
try:
    sign_in = deformable.license.start_sign_in()
    url, code = sign_in.verification_url, sign_in.user_code
    print(f"Open {url} and approve the code {code}")
except deformable.LicenseError as error:
    message = error.message
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_start_sign_in`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_start_sign_in) · [Rust `start_sign_in`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#start_sign_in)

## license.wait_for_sign_in

**Function** · `deformable.license.wait_for_sign_in`

```python
def wait_for_sign_in(
    timeout: float = DEFAULT_TIMEOUT,
) -> LicenseStatus | None
```

Waits at most `timeout` seconds for the person to approve the sign-in [`start_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-start_sign_in) started, polling the licensing service as often as it allows, then takes this device a free seat of the subscription. It never returns before `timeout` without an answer, so a host loop of short waits does not spin, and it may return up to 25 seconds after it: a poll already sent is given 10 seconds to answer, and once approved, the seat is given 15 seconds of its own. It waits with the global interpreter lock released, so a host with an interface runs it off its main thread. A development build of the library has licensing off and gives its state at once.

**Parameters**

- `timeout` (`float`): How long to wait for the approval, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds. 5 seconds suits a host loop that also watches for its user cancelling.

**Returns**

[`LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus) or `None`: The license state once the account approved the sign-in, [`STANDALONE_SUBSCRIPTION`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-standalone_subscription) when a seat was free; None while it has not yet.

**Raises**

[`DeformableError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#deformableerror) with one of these statuses; the license ones raise its subclass [`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror):

- [`INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-invalid_argument): No sign-in was started in this program ("Sign in first"), or the program uses an Application license.
- [`LICENSE_SIGN_IN_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_sign_in_failed): The sign-in was denied, its code is no longer valid, this version of the library may not sign in, or the service could not read the request: the sign-in is forgotten, and a new one starts with [`start_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-start_sign_in).
- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact.
- [`LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_storage_failed): The sign-in could not be stored; the message names the folder.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

`ValueError` when `timeout` is NaN, 0 or less.

**Example**

```python
status = None
while status is None:
    status = deformable.license.wait_for_sign_in(5.0)
# STANDALONE_SUBSCRIPTION, or SUBSCRIPTION_NO_SEAT if no seat is free
state = status.state
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_wait_for_sign_in`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_wait_for_sign_in) · [Rust `wait_for_sign_in`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#wait_for_sign_in)

## license.take_over

**Function** · `deformable.license.take_over`

```python
def take_over(timeout: float = DEFAULT_TIMEOUT) -> LicenseStatus
```

Uses the signed-in Standalone subscription on this device instead of another, waiting at most `timeout` seconds: takes a free seat, or else the seat refreshed longest ago, whose device stops at its next check-in. A host offers it in [`SUBSCRIPTION_NO_SEAT`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-subscription_no_seat). It waits on the network with the global interpreter lock released, so a host with an interface runs it off its main thread.

**Parameters**

- `timeout` (`float`): How long to wait for the service, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds.

**Returns**

[`LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus): The license state after the call. After a license failure, [`status()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-status) gives the state to show.

**Raises**

[`DeformableError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#deformableerror) with one of these statuses; the license ones raise its subclass [`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror):

- [`INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-invalid_argument): No sign-in is stored, or the stored sign-in ended ("Sign in first"), a Standalone key is stored, or the program uses an Application license.
- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): The service could not be reached or did not answer, its answer did not verify or this device's clock contradicts it, or [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact.
- [`LICENSE_SIGN_IN_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_sign_in_failed): The service could not read the request.
- [`LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_storage_failed): The per-user license store could not be written; the message names its folder.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

`ValueError` when `timeout` is NaN, 0 or less.

**Example**

```python
state = deformable.license.status().state
if state == deformable.LicenseState.SUBSCRIPTION_NO_SEAT:
    status = deformable.license.take_over()
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_take_over`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_take_over) · [Rust `take_over`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#take_over)

## license.sign_out

**Function** · `deformable.license.sign_out`

```python
def sign_out(timeout: float = DEFAULT_TIMEOUT) -> LicenseStatus
```

Signs out of the Standalone subscription on this device at once, even offline, so Free runs; then frees this device's seat and ends its session with the licensing service, waiting at most `timeout` seconds. Without a sign-in, or under an Application license, it does nothing and succeeds. It waits on the network with the global interpreter lock released, so a host with an interface runs it off its main thread.

**Parameters**

- `timeout` (`float`): How long to wait for the service, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds.

**Returns**

[`LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus): The license state after the sign-out. After a failure, [`status()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-status) gives the state to show.

**Raises**

[`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror) with one of these statuses:

- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): The seat could not be freed: the service could not be reached, or [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact. The sign-in is forgotten here all the same, and the seat frees itself within a day.
- [`LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_storage_failed): The per-user license store could not be changed; the message names its folder.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

`ValueError` when `timeout` is NaN, 0 or less.

**Example**

```python
status = deformable.license.sign_out()
status.signed_in
# False
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_sign_out`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_sign_out) · [Rust `sign_out`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#sign_out)

## license.activate

**Function** · `deformable.license.activate`

```python
def activate(
    license_key: str,
    timeout: float = DEFAULT_TIMEOUT,
) -> LicenseStatus
```

Activates `license_key`, a Standalone or an Application license key, told apart by their shape: a Standalone key is `tgdfp-xxxxx-xxxxx-xxxxx-xxxxx`, an Application key `tgdfp-<payload hex>-<signature hex>`.

A Standalone key is activated on this device with the licensing service, waiting at most `timeout` seconds; the state is then [`STANDALONE_LICENSE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-standalone_license). The key already stored here renews its lease instead. It waits on the network with the global interpreter lock released, so a host with an interface runs it off its main thread.

An Application key is checked offline, without waiting, and licenses this program for as long as it runs: nothing is stored or sent, so the program calls this at every start, as its first Deformable call, before status and refresh. The state is then [`APPLICATION_LICENSE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-application_license), or [`APPLICATION_TRIAL`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-application_trial) for a trial key. The same key again changes nothing. A full key covers the versions of the library released until its updates end, and keeps working in them forever. The plugins refuse an Application key. A development build of the library checks the key the same way but stays [`DEVELOPMENT`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestate-development).

The error's message says why the key was not activated, written to show the user as it is.

**Parameters**

- `license_key` (`str`): The license key, where letter case does not matter and spaces and line breaks are removed.
- `timeout` (`float`): How long to wait for the service, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds. An Application key never waits.

**Returns**

[`LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus): The license state after the activation. After a license failure, [`status()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-status) gives the state to show.

**Raises**

[`DeformableError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#deformableerror) with one of these statuses; the license ones raise its subclass [`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror):

- [`INVALID_ARGUMENT`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-invalid_argument): `license_key` is no license key or an Application key that does not verify; another Standalone key is stored on this device: deactivate it first; a Standalone subscription is signed in: sign out first; another Application key is already set in this program; or it is a Standalone key in a program on an Application license. Nothing changes then.
- [`LICENSE_KEY_REJECTED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_key_rejected): The service refused the Standalone key: it does not exist, was revoked or refunded, is not for Deformable, or every seat of the license is in use. Or the Application key was revoked, is a trial key that ended, covers only versions released before this one, or was given inside a plugin host.
- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): The service could not be reached or did not answer, its answer did not verify or this device's clock contradicts it, or [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact.
- [`LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_storage_failed): The per-user license store could not be written; the message names its folder.

`ValueError` when `license_key` is not a string, is empty or blank, or holds a NUL character, or when `timeout` is NaN, 0 or less.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

**Example**

```python
key = "tgdfp-xxxxx-xxxxx-xxxxx-xxxxx"
try:
    status = deformable.license.activate(key)
except deformable.DeformableError as error:
    print(error.message)
# An app on an Application license activates its key, exactly as
# copied from the Licenses page, first thing at every start.
# This one is shaped like an Application key but signed by
# nobody, so it is refused.
application_key = "tgdfp-7b2276657273696f6e223a317d-" + "0" * 128
try:
    status = deformable.license.activate(application_key)
except deformable.DeformableError as error:
    print(error.message)
# This license key is not valid
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_activate`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_activate) · [Rust `activate`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#activate)

## license.deactivate

**Function** · `deformable.license.deactivate`

```python
def deactivate(timeout: float = DEFAULT_TIMEOUT) -> LicenseStatus
```

Forgets the Standalone license on this device at once, even offline, so Free runs; then frees its seat with the licensing service, waiting at most `timeout` seconds, so the key can be activated on another device. When the seat cannot be freed, the customer removes this device on the Licenses page. With no key stored, or under an Application license, it does nothing and succeeds. It waits on the network with the global interpreter lock released, so a host with an interface runs it off its main thread.

**Parameters**

- `timeout` (`float`): How long to wait for the service, in seconds, rounded up to whole milliseconds. The library counts anything above 60 seconds as 60 seconds.

**Returns**

[`LicenseStatus`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#licensestatus): The license state after the deactivation. After a failure, [`status()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-status) gives the state to show.

**Raises**

[`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror) with one of these statuses:

- [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable): The seat could not be freed: the service could not be reached, or [`set_online_access()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-set_online_access) forbade every contact. The license is forgotten here all the same.
- [`LICENSE_STORAGE_FAILED`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_storage_failed): The per-user license store could not be changed; the message names its folder.

`TypeError` when `timeout` is a bool, or neither an int nor a float.

`ValueError` when `timeout` is NaN, 0 or less.

**Example**

```python
status = deformable.license.deactivate()
status.has_license_key
# False
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_deactivate`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_deactivate) · [Rust `deactivate`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#deactivate)

## license.set_online_access

**Function** · `deformable.license.set_online_access`

```python
def set_online_access(allowed: bool) -> None
```

Allows (the default) or forbids every contact with the licensing service from this process, for a host whose user turned online access off. Forbidden, nothing is sent: [`refresh()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-refresh), [`start_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-start_sign_in), [`wait_for_sign_in()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-wait_for_sign_in), [`take_over()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-take_over) and [`activate()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-activate) raise [`LicenseError`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#licenseerror) with [`LICENSE_SERVICE_UNAVAILABLE`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/errors/#status-license_service_unavailable) and change nothing, [`sign_out()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-sign_out) and [`deactivate()`](https://help.tangerina.io/deformable/v0.8.0/api-references/python/license/#license-deactivate) forget the sign-in or license without freeing its seat, and the library never renews a lease on its own, so it runs out as it would offline. An Application key is checked offline and is not affected. It grants nothing, and it fails only when the library fails inside.

**Parameters**

- `allowed` (`bool`): True allows every contact, False forbids them.

**Raises**

Only the errors every call can raise, which the [conventions](https://help.tangerina.io/deformable/v0.8.0/api-references/python/overview/#conventions) describe.

**Example**

```python
# The user turned online access off in the host's settings.
deformable.license.set_online_access(False)
```

**See also** [Guide: License](https://help.tangerina.io/deformable/v0.8.0/user-guides/python/getting-started/#license) · [C `deformable_license_set_online_access`](https://help.tangerina.io/deformable/v0.8.0/api-references/c/license/#deformable_license_set_online_access) · [Rust `set_online_access`](https://help.tangerina.io/deformable/v0.8.0/api-references/rust/license/#set_online_access)
