> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qanapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication & Token Lifecycle

## Login, Logoff and be aware of your token

### Login

```ts theme={null}
const token = await client.auth.login(email, password);
```

Sample response:

```json theme={null}
{
  "access_token": "YOUR_JWT_TOKEN",
  "token_type": "bearer",
  "expires_in": 3600 //1 hour default
}
```

### Refresh Token

```ts theme={null}
await client.auth.refreshToken({
  headers: { Authorization: `Bearer ${token}` },
});
```

Sample response:

```json theme={null}
{
  "access_token": "YOUR_JWT_TOKEN",
  "token_type": "bearer",
  "expires_in": 3600 //1 hour default
}
```

### Get User Details

```ts theme={null}
await client.auth.retrieveUserDetails({
  headers: { Authorization: `Bearer ${token}` },
});
```

Sample response:

```json theme={null}
{
  "id": 2,
  "email": "user@qanapi.com",
  "name": "User",
  "first_login": 1,
  "email_verified_at": true,
  "gravatar_url": "https://www.gravatar.com...",
  "roles": [ "admin" ]
}
```

### User Logout

```ts theme={null}
await client.auth.retrieveUserDetails({
  headers: { Authorization: `Bearer ${token}` },
});
```

Sample response:

```json theme={null}
{ 
  "user": "user@qanapi.com", 
  "message": "Successfully logged out"
}
```
