Auth

class Auth(api: UmamiApi)

Provides authentication functionalities for interacting with the Umami API. This class handles user login, logout, and token verification.

Parameters

api

The UmamiApi instance used for making HTTP requests.

Constructors

Link copied to clipboard
constructor(api: UmamiApi)

Types

Link copied to clipboard
interface Login

Functions

Link copied to clipboard
suspend fun login(request: Auth.Login.Request): Session

Logs in a user with the provided Login.Request object. On successful login, the received JWT token is stored for subsequent authenticated requests.

suspend fun login(apiKey: String): Session

Logs in a user using an API key. This method is intended for use with Umami Cloud or instances where API key authentication is enabled.

suspend fun login(username: String, password: String): Session

Logs in a user with the provided username and password. This function constructs a Login.Request and then calls the overloaded login function.

Link copied to clipboard
suspend fun logout()

Logs out the current user.

Link copied to clipboard
suspend fun verify(): User

Verifies the current authentication token and retrieves the details of the logged-in user.