# Director Authentication

Director supports two authentication methods: JWT-based login through the Director Console and session-based login through LPSM. API access requires an authentication token, which allows authorized users and admins to perform administrative actions on Fabric-enabled Logpoints.

**Through Director Console**

User authentication in Director Console occurs through token-based authentication using JSON Web Tokens (JWT).

**Through LPSM**

User authentication in LPSM occurs through session-based authentication, where sessions for each user are stored in browser cookies.

#### Get Authentication Token

You need an authentication token to use APIs. An API Authentication Token acts as the authorization key that lets you access the[ Director Console API](https://docs.logpoint.com/director/director-overview#director-console). You can perform administrative tasks in Fabric-enabled Logpoints using the tokens.

Only **admins** and **users** can generate tokens.

<details>

<summary>Generating a Token</summary>

You can create multiple tokens with the same **Token Identifier**.

1. Click the **Profile** icon at the top of the page.
2. In **Generate Token**, enter a **Token Identifier** and your **Password**.
3. Enable **Always Active** to generate a token that does not expire. If disabled, the token expires after 8 hours.\
   ![](https://3198401301-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhzE0kPDYI002AO7fHbFv%2Fuploads%2FXJTCMgHPFf2CtYW9BPjY%2Fimage.png?alt=media\&token=f450148e-cfd1-433a-94da-c04d4f8d6dd9)
4. Click **Generate Token**.\
   ![](https://3198401301-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhzE0kPDYI002AO7fHbFv%2Fuploads%2Fc1xI9hLbmM5Xch0wEDPe%2Fimage.png?alt=media\&token=81bd6453-058d-4a60-a21a-7db7472d793a)

The **Token** and the **Secret Key** are generated only once for a **Token Identifier**. We recommend you make a copy and store it in a secure location. Click the **Copy** icon to copy the **Token** and the **Secret Key**.

<div align="left"><figure><img src="https://3198401301-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhzE0kPDYI002AO7fHbFv%2Fuploads%2FRUxXoQhNGivpYscyOTxq%2Fimage.png?alt=media&#x26;token=6e9dd871-e0f8-415a-852b-6aa009727b35" alt="" width="366"><figcaption><p>Copying the Token and the Secret Key</p></figcaption></figure></div>

{% hint style="info" %}

* You can generate a new token at any time. It does not invalidate the previous token.
* Go to [Director Console API Documentation](https://docs.logpoint.com/director/director-apis/director-console-api-documentation) to view the APIs and endpoints.
  {% endhint %}

</details>

<details>

<summary>Invalidating a Token</summary>

1. Click the **Profile** icon at the top of the page.
2. Click the **Delete** icon under **Actions**.\
   ![](https://3198401301-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FhzE0kPDYI002AO7fHbFv%2Fuploads%2FP4Yq2InGyux1Q8eMYmBa%2Fimage.png?alt=media\&token=14293755-3fe3-45f4-a51c-17d828679443)
3. Click **OK**.

</details>

<details>

<summary>Refreshing a Token from API</summary>

You can use a secret key to refresh a token at any time. Refreshing generates a new token and secret key pair. The token expires after 8 hours.&#x20;

{% hint style="info" %}
Note: You must refresh the token within 72 hours.
{% endhint %}

If you use an expired token to execute an API command, you will get:

```
{
    "status": "Error",
    "message": "Invalid Token"
}
```

To refresh a token, send a POST request to /refreshToken with the expired token in the Authorization header and a JSON payload including the secretKey:

POST example:

```
POST /refreshToken HTTP/1.1
Host: api-server-host-name
Content-Type: application/json
Authorization: current-api-token-string

{
   "secretKey": "secret-key-associated-with-the-current-token"
}
```

Success response:

```
{
    "status": "Success",
    tokenDetails: {
        "token": "eyJhbGciOiJIUzI1NiIXVCJ9.eyJ1zQ0LCJleHAiOjE1MzE3NDMxNDR9.Zk05wiJuBpeEnMYE3AFkPtw",
        "secretKey": "7ac18dd3-aca9-478e-822c-b931e3b849ab"
    }
}
```

Common error responses while requesting a new token:

1. When no secret key is provided:

   ```
   {

       "status": "Error",
       "message": "No secret key provided"

   }
   ```
2. When the secret key is not the same as the generated secret key:

   ```
   {

       "status": "Error",
       "message": "Invalid secret key"

   }
   ```
3. When the authorization token is invalid:

   ```
   {

       "status": "Error",
       "message": "Invalid Token"

   }
   ```
4. When the authorization token is empty:

   ```
   {

       "status": "Error"
       "message": "Missing authentication"

   }
   ```
5. When the authorization token is random words:

   ```
   {

       "status": "Error"
       "message": "Invalid token format"

   ```

</details>
