> This page is for version V3 - Beta (default).
> For other versions, use one of these documentation indexes:
> - V3 - Beta (default): https://docs.authlyx.dev/v3/llms.txt
> - V2 - Legacy: https://docs.authlyx.dev/v2/llms.txt
> - V1 - End of support: https://docs.authlyx.dev/v1/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.authlyx.dev/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.authlyx.dev/_mcp/server.

# Login

> Sign in with a license, username and password, or an approved device.

Call Login after Initialize succeeds. Choose the method that matches the access type you created in the dashboard. A username login requires both username and password. Device login sends the configured system ID as `sid`. The Windows SDK defaults use the current Windows account SID; they do not read a motherboard or processor ID. See [Use device login without a login page](/v3/guides/device-login) to find the ID, add it to the dashboard and configure a custom platform ID.

Each code tab lists three choices for reference. Use only one of them in your sign-in flow. Calling all three in order would attempt three sign-ins, not show three ways the same login works.

**SDK version:** V3 Beta. These examples use the current downloads. V1 and V2 use different APIs; choose them in the version selector.

Each example assumes `app` is the AuthlyX client you created in [Connect your app](/v3/guides/quickstart). When a method takes a callback, AuthlyX calls it after the reply arrives. A name such as `result` inside that callback is created there; you do not declare it at the top of your file. For C++ futures, Python or JavaScript `await`, Java futures, Go errors and Rust `?`, read [Results](/v3/sdks/methods/results).

#### C\#

```csharp
app.login("YOUR_LICENSE_KEY", result =>
{
    if (result.ok)
        Console.WriteLine("Signed in");
    else
        Console.WriteLine(result.message);
});

app.login("YOUR_USERNAME", "YOUR_PASSWORD", result =>
{
    if (result.ok)
        Console.WriteLine("Signed in");
    else
        Console.WriteLine(result.message);
});

app.deviceLogin(result =>
{
    if (result.ok)
        Console.WriteLine("Signed in");
    else
        Console.WriteLine(result.message);
});
```

#### C++

```cpp
auto loginResult = app.login("YOUR_LICENSE_KEY").get();
if (loginResult.ok())
    std::cout << "Signed in\n";
else
    std::cout << loginResult.code << ": " << loginResult.message << '\n';
```

This C++ example uses a license. For username and password, replace the call with `app.login("YOUR_USERNAME", "YOUR_PASSWORD")`. For device sign-in, use `app.deviceLogin()`. Both return a future too, so call `.get()` to wait for the reply. Do that on a worker thread in a graphical app, not on its UI thread.

#### Python

```python
app.login("YOUR_LICENSE_KEY", completed=lambda result: print("Signed in" if result.ok else result.message))
app.login("YOUR_USERNAME", "YOUR_PASSWORD", completed=lambda result: print("Signed in" if result.ok else result.message))

async def sign_in_with_device():
    result = await app.deviceLogin()
    print("Signed in" if result.ok else result.message)
```

#### JavaScript / Node.js

```javascript
app.login("YOUR_LICENSE_KEY", result => console.log(result.ok ? "Signed in" : result.message));
app.login("YOUR_USERNAME", "YOUR_PASSWORD", result => console.log(result.ok ? "Signed in" : result.message));
app.deviceLogin().then(result => console.log(result.ok ? "Signed in" : result.message));
```

#### TypeScript

```typescript
app.login("YOUR_LICENSE_KEY", result => console.log(result.ok ? "Signed in" : result.message));
app.login("YOUR_USERNAME", "YOUR_PASSWORD", result => console.log(result.ok ? "Signed in" : result.message));
app.deviceLogin().then(result => console.log(result.ok ? "Signed in" : result.message));
```

#### Java

```java
app.login("YOUR_LICENSE_KEY").thenAccept(result -> System.out.println(result.ok() ? "Signed in" : result.message()));
app.login("YOUR_USERNAME", "YOUR_PASSWORD").thenAccept(result -> System.out.println(result.ok() ? "Signed in" : result.message()));
app.deviceLogin().thenAccept(result -> System.out.println(result.ok() ? "Signed in" : result.message()));
```

#### Go

```go
licenseResult, err := app.LicenseLogin(ctx, "YOUR_LICENSE_KEY")
if err != nil {
    return err
}
if licenseResult.Success {
    fmt.Println("Signed in")
} else {
    fmt.Println(licenseResult.Message)
}
```

For username login, use `app.Login(ctx, "YOUR_USERNAME", "YOUR_PASSWORD")`. For device login, use `app.DeviceLogin(ctx)`. Each returns `(Result, error)`; check `err` first, then check `Result.Success`.

#### Rust

```rust
let login_result = app.licenseLogin("YOUR_LICENSE_KEY").await?;
if login_result.success {
    println!("Signed in");
} else {
    println!("{}", login_result.message);
}
```

For username login, use `app.login("YOUR_USERNAME", "YOUR_PASSWORD")`. For device login, use `app.deviceLogin()`. Each returns a response or an SDK error. `?` handles the SDK error; `success` tells you whether AuthlyX approved the sign-in.

The three calls are alternatives. Do not run all of them for one sign-in flow. Each successful login creates a session bound to the identity that signed in. See [User Data](/v3/sdks/methods/user-data) for the current identity and [Heartbeats](/v3/sdks/methods/heartbeats) for continued session checks.