> 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.

# Results

> See what a result variable is and how each language reports success or failure.

Every SDK call finishes later, after AuthlyX replies. The result is the reply your code receives. It contains `ok` or `success`, an error `code`, a readable `message`, and operation data when there is any.

You do not declare a magic variable named `result` at the top of your file. In the examples, `result` is a temporary name created by a callback or a local assignment. You can rename it to `loginResult`, `sessionResult` or anything clear to you.

## C\#

In a callback, the parameter between the parentheses is the result variable. The SDK calls this code after the network request finishes.

```csharp
app.login("YOUR_LICENSE_KEY", loginResult =>
{
    if (loginResult.ok)
        Console.WriteLine("Access granted");
    else
        Console.WriteLine(loginResult.code + ": " + loginResult.message);
});
```

You do not need to create `loginResult` before this call. It only exists inside the braces. In a Windows Forms app, update controls from the callback using the UI thread rules of your framework.

## C++

Network methods return a `std::future`. Calling `.get()` waits for that future and gives you its `result`. This example suits a console program or a worker thread. Do not call `.get()` on a graphical app's UI thread, because that thread will wait and the window may stop responding.

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

`auto` asks C++ to work out the result type. `.get()` is not a property on the AuthlyX result. It is the way this example waits for the future to finish and takes its value.

## Python

Use `await` inside an `async def` function. It waits for this request while letting Python's event loop run other work.

```python
async def sign_in():
    login_result = await app.login("YOUR_LICENSE_KEY")
    if login_result.ok:
        print("Access granted")
    else:
        print(f"{login_result.code}: {login_result.message}")
```

Start `sign_in()` from the asyncio event loop used by your program. The SDK also has callback forms for common methods; in those forms, the callback parameter is the result.

## JavaScript / Node.js

Put `await` inside an `async` function. It does not block Node.js's event loop.

```javascript
async function signIn() {
    const loginResult = await app.login("YOUR_LICENSE_KEY");
    if (loginResult.ok) {
        console.log("Access granted");
    } else {
        console.log(`${loginResult.code}: ${loginResult.message}`);
    }
}
```

The SDK also accepts a callback for common methods. In `app.login(key, loginResult => { ... })`, the SDK supplies `loginResult` when the request finishes.

## TypeScript

The TypeScript SDK uses the same pattern as JavaScript. `loginResult` is inferred from the SDK method, so you do not need to declare its type for this example.

```typescript
async function signIn(): Promise<void> {
    const loginResult = await app.login("YOUR_LICENSE_KEY");
    if (loginResult.ok) {
        console.log("Access granted");
    } else {
        console.log(`${loginResult.code}: ${loginResult.message}`);
    }
}
```

## Java

Java methods return a `CompletableFuture`. `thenAccept` gives you the result when the request finishes without making the current thread wait.

```java
app.login("YOUR_LICENSE_KEY").thenAccept(loginResult -> {
    if (loginResult.ok()) {
        System.out.println("Access granted");
    } else {
        System.out.println(loginResult.code() + ": " + loginResult.message());
    }
});
```

The name `loginResult` is a parameter created by `thenAccept`. You can choose a different name. Avoid `.join()` on a UI thread because it waits for the request to finish.

## Go

Go returns two values: `loginResult` and `err`. The method completes the request before returning. `err` is for a request or SDK failure; `loginResult.Success` tells you whether AuthlyX accepted the sign-in.

```go
func signIn(ctx context.Context, app *authlyx.AuthlyX) error {
    loginResult, err := app.LicenseLogin(ctx, "YOUR_LICENSE_KEY")
    if err != nil {
        return err
    }
    if loginResult.Success {
        fmt.Println("Access granted")
    } else {
        fmt.Println(loginResult.Code + ": " + loginResult.Message)
    }
    return nil
}
```

`:=` creates the two local variables. `ctx` is the request context passed into this function. A Go `error` means the request could not complete normally; `loginResult.Success == false` means AuthlyX answered but denied this sign-in.

## Rust

Rust methods return `Result<Response, Error>`. `.await` waits for the network operation inside an async function. `?` means "if the SDK returned an error, return that error from this function now." If the request completed and AuthlyX rejected access, inspect `login_result.success`.

```rust
async fn sign_in(app: &AuthlyX) -> Result<(), Box<dyn std::error::Error>> {
    let login_result = app.licenseLogin("YOUR_LICENSE_KEY").await?;
    if login_result.success {
        println!("Access granted");
    } else {
        println!("{}: {}", login_result.code, login_result.message);
    }
    Ok(())
}
```

Here `?` handles a request error by returning it from `sign_in`. If AuthlyX returns a normal denial, the request itself succeeded, so the code reaches the `else` branch and prints the server message.

## A failed sign-in versus a connection problem

If `ok` or `success` is false, AuthlyX answered and did not approve the operation. Show the message or handle the stable code. A timeout or network error means the SDK could not confirm the answer. Do not treat a network error as a ban, and do not unlock protected features when no successful result arrived.