> For the complete documentation index, see [llms.txt](https://developer.laurel.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.laurel.ai/guides/authentication.md).

# Authentication

We use OAuth2 authentication, here's how to retrieve an M2M access token. These tokens can be used with our [two public facing APIs](https://developer.laurel.ai/guides/public-api-endpoints):

* Time Service
* Identity Service

## Getting Started

With a Super Customer Admin role, you can generate and manage API credentials directly from the Laurel Admin Center. Please follow instructions laid out in this [help article](https://help.laurel.ai/en/articles/15927367-getting-started-with-the-laurel-api) to generate your credentials.

*Direct link to the API credential tab in the Laurel Admin:* <https://admin.laurel.ai/company/security?tab=m2m>

Your credentials are used to obtain a short-lived access token, which you then include in every API request.

## Retrieving API Credentials

With the clientId and clientSecret you can call our token exchange endpoint to generate an M2M access token.

Here's a sample request:

```
POST https://identity.laurel.ai/api/v1/oauth/token

{
    "audience": "https://timeautomation.com",
    "grant_type": "client_credentials",
    "client_id": "<clientId>",
    "client_secret": "<clientSecret>"
}
```

```
Here's a sample response:

{
    "access_token": "<token>",
    "expires_in": 86400,
    "token_type": "Bearer"
}
```

The returned token can be used with your specific `customerId` in Time Service and Identity Service
