# Authentication

## How this example works

OpenLoyalty uses JWT Tokens to authenticate all API calls.

Properly setting up authentication is crucial for maintaining application security and ensuring uninterrupted service. This helps avoid issues such as excessive request rates or the use of invalid or expired tokens.

***

## Try yourself <a href="#to-try-it-yourself" id="to-try-it-yourself"></a>

* Login with the admin username and password\
  Endpoint: `POST /api/admin/login_check`
* Save `token` and `refresh_token` from the responses
* Refresh your previously saved token\
  Endpoint: `POST /api/token/refresh`
* Input the token in the header for all the subsequent requests&#x20;

***

## Endpoints used

{% openapi src="<https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20(1).json>" path="/api/admin/login\_check" method="post" %}
[openapi-5.61.0 (1).json](https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20\(1\).json)
{% endopenapi %}

{% openapi src="<https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20(1).json>" path="/api/token/refresh" method="post" %}
[openapi-5.61.0 (1).json](https://content.gitbook.com/content/gIv2CyIIYf7vRfuhMKQ6/blobs/2xnMWXnOETp8Vxl2YZoi/openapi-5.61.0%20\(1\).json)
{% endopenapi %}

***

## More resources

For a detailed overview and description of the authentication flow, please refer to these articles:

{% content-ref url="broken-reference" %}
[Broken link](https://help.openloyalty.io/technical-guide/getting-started-guide/broken-reference)
{% endcontent-ref %}

{% content-ref url="<https://app.gitbook.com/s/cNVX03KZzmrGwJihLiEx/main-features/settings/admins>" %}
[Admins](https://app.gitbook.com/s/cNVX03KZzmrGwJihLiEx/main-features/settings/admins)
{% endcontent-ref %}

{% content-ref url="broken-reference" %}
[Broken link](https://help.openloyalty.io/technical-guide/getting-started-guide/broken-reference)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.openloyalty.io/technical-guide/getting-started-guide/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
