# `Arangox.API.Authentication`
[🔗](https://github.com/ArangoDB-Community/arangox/blob/v0.8.0/lib/arangox/api/authentication.ex#L1)

ArangoDB's Authentication operations.

Every function takes the pool as its first argument and returns the decoded
response body. See `Arangox.API.Client` for the options they all accept and
for what a `404` returns.

# `all_access_tokens`

```elixir
@spec all_access_tokens(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

List all access tokens

List the access tokens for a given user.

This only returns the access token metadata.
The actual access token strings are only shown when creating tokens. 

The user account you authenticate with needs to have administrate access
to the `_system` database if you want to list the access tokens for a
different user. You can always list your own access tokens,
regardless of database access levels.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "tokens" => []
    }

# `all_access_tokens!`

```elixir
@spec all_access_tokens!(Arangox.conn(), binary(), keyword()) :: term()
```

List all access tokens. Raises on error.

See `all_access_tokens/2`.

# `create_access_token`

```elixir
@spec create_access_token(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Create an access token

Create a new access token for the given user.

The response includes the actual access token string that you need to
store in a secure manner. It is only shown once.

The user account you authenticate with needs to have administrate access
to the `_system` database if you want to create an access token for a
different user. You can always create an access token for yourself,
regardless of database access levels.

# `create_access_token!`

```elixir
@spec create_access_token!(Arangox.conn(), binary(), term(), keyword()) :: term()
```

Create an access token. Raises on error.

See `create_access_token/3`.

# `create_session_token`

```elixir
@spec create_session_token(Arangox.conn(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Create a JWT session token

Obtain a JSON Web Token (JWT) from the credentials of an ArangoDB user account
or a user's access token.
You can use the JWT in the `Authorization` HTTP header as a `Bearer` token to
authenticate requests.

The lifetime for the token is controlled by the `--server.session-timeout`
startup option.

# `create_session_token!`

```elixir
@spec create_session_token!(Arangox.conn(), term(), keyword()) :: term()
```

Create a JWT session token. Raises on error.

See `create_session_token/2`.

# `delete_access_token`

```elixir
@spec delete_access_token(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}
```

Delete an access token

Delete an access token with the specified identifier for the given user.

The user account you authenticate with needs to have administrate access
to the `_system` database if you want to delete an access token for a
different user. You can always delete your own access tokens,
regardless of database access levels.

# `delete_access_token!`

```elixir
@spec delete_access_token!(Arangox.conn(), binary(), binary(), keyword()) :: term()
```

Delete an access token. Raises on error.

See `delete_access_token/3`.

# `reload_server_jwt_secrets`

```elixir
@spec reload_server_jwt_secrets(
  Arangox.conn(),
  keyword()
) :: {:ok, term()} | {:error, Exception.t()}
```

Hot-reload the JWT secret(s) from disk

Sending a request without payload to this endpoint reloads the JWT secret(s)
from disk. Only the files specified via the arangod startup option
`--server.jwt-secret-keyfile` or `--server.jwt-secret-folder` are used.
It is not possible to change the locations where files are loaded from
without restarting the process.

To utilize the API a superuser JWT token is necessary, otherwise the response
will be _HTTP 403 Forbidden_.

# `reload_server_jwt_secrets!`

```elixir
@spec reload_server_jwt_secrets!(
  Arangox.conn(),
  keyword()
) :: term()
```

Hot-reload the JWT secret(s) from disk. Raises on error.

See `reload_server_jwt_secrets/1`.

# `server_jwt_secrets`

```elixir
@spec server_jwt_secrets(
  Arangox.conn(),
  keyword()
) :: {:ok, term()} | {:error, Exception.t()}
```

Get information about the loaded JWT secrets

Get information about the currently loaded secrets.

To utilize the API a superuser JWT token is necessary, otherwise the response
will be _HTTP 403 Forbidden_.

## Returns

Recorded against ArangoDB 3.12.10:

    %{
      "code" => integer,
      "error" => boolean,
      "result" => %{
        "active" => %{
          "sha256" => string
        },
        "passive" => []
      }
    }

# `server_jwt_secrets!`

```elixir
@spec server_jwt_secrets!(
  Arangox.conn(),
  keyword()
) :: term()
```

Get information about the loaded JWT secrets. Raises on error.

See `server_jwt_secrets/1`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
