Login()

login(dto: any, signal?: AbortSignal)

Logs in a user by verifying their credentials. If successful, it returns an authentication token that can be used for further requests.

await client.auth().login({ username: "mike", password: "mikes-wife-birthday" })

Result

The login() method returns a token object containing both an access token and a refresh token. However, if the request is made from a browser environment, only the access token is included in the response, while the refresh token is stored in an HTTP-only cookie.

const token = await client.auth().login({ username: "mike", password: "mikes-wife-birthday" })
//console.log(token)

// result:
// {
//      access: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
// }

Suggestion

If you need to save the token for future use, retrieve it from the client.auth().on("login", token => { /* save token */ }) event instead of this result.

Edit this page on Github
© 2025 kav3.com. Crafted with and dedication.