> For the complete documentation index, see [llms.txt](https://docs.weka.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.weka.io/4.0/usage/security/obtain-authentication-tokens.md).

# Obtain authentication tokens

The authentication tokens include two types: an access token and a refresh token.

* **Access token:** The access token is a short-live token (five minutes) used for accessing the Weka system API and to allow the mounting of secure filesystems.
* **Refresh token:** The refresh token is a long-live token (one year) used for obtaining an additional access token.

**Procedure**

Do one of the following:

* To obtain the refresh token and access token, **through the CLI**, log in to the system using the command: `weka user login`.

  The system creates an authentication token file and saves it in: `~/.weka/auth-token.json`. The token file contains both the access token and refresh token.

![Auth-token file content example](https://661826007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuOB5D2WMRjXBnChPFTrk%2Fuploads%2FO6Mof7H2uHFyRQCTY6HV%2Fwmng_auth_token_example.png?alt=media\&token=8243d807-ea0b-4a12-91c0-277e768fa2fa)

* To obtain the refresh token and access token, **through the REST API,** use the `POST /login`. The API returns the token in the response body.

![REST API login response example](https://661826007-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FuOB5D2WMRjXBnChPFTrk%2Fuploads%2FtZJ68t9fxjj8EP96Fmlf%2Fwmng_auth_token_api_example.png?alt=media\&token=1fe2045e-7b28-4a33-9624-a1f48876919f)

### Generate an access token for API usage (for internal users only)

When working with the REST API, internal Weka users may require using a longer-lived access token (a token that doesn't require a refresh every 5 minutes).

You can generate a longer-lived access token using the CLI command:

`weka user generate-token [--access-token-timeout timeout]`

The default timeout is 30 days.

To revoke the access and refresh tokens, use the CLI command: `weka user revoke-tokens`.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.weka.io/4.0/usage/security/obtain-authentication-tokens.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
