# Setting up Auth0 integration

Creating a credential for a **Machine-to-Machine (M2M)** application in Auth0—commonly referred to as the **Client Credentials flow**—is the standard way to authorize backend services, CLIs, or daemons without user intervention.

Follow this guide to set up your credentials and retrieve your first access token.

## 1. Create the Machine-to-Machine Application

First, you need to register the "client" that will be requesting the tokens.

1. Log in to your **Auth0 Dashboard**.
2. Navigate to **Applications > Applications** in the left-hand sidebar.
3. Click the **+ Create Application** button.
4. **Name your app** (e.g., `Payment-Processor-Service`).
5. Select **Machine to Machine Applications** as the application type.
6. Click **Create**.

## 2. Authorize the Application for an API

Unlike user logins, M2M tokens are issued specifically to access a protected resource (an API).

1. Immediately after clicking "Create," a popup will ask you to **Select an API**.
   - _Note: If you haven't created your own API yet, you can select the **Auth0 Management API** to test the flow._
2. Select the **Scopes** (permissions) you want this credential to have (e.g., `read:users`, `write:orders`).
3. Click **Authorize**.

## 3. Retrieve Your Credentials

Now that the app is authorized, you can find the credentials needed for the handshake.

1. In your application's settings, go to the **Settings** tab.
2. Locate and copy the following three values:
   - **Domain:** (e.g., `your-tenant.auth0.com`)
   - **Client ID:** The public identifier for your app.
   - **Client Secret:** The password for your app (**Keep this private**).

## 4. Test the Credential

Below, the raw code that Mindflow will perform to retrieve the JWT token.

```bash
curl --request POST \
  --url https://YOUR_DOMAIN/oauth/token \
  --header 'content-type: application/json' \
  --data '{
    "client_id":"YOUR_CLIENT_ID",
    "client_secret":"YOUR_CLIENT_SECRET",
    "audience":"YOUR_API_IDENTIFIER",
    "grant_type":"client_credentials"
  }'
```

- In Mindflow, head to the Environments panel
- Then click Create a credential within an Environment

  <div class="docs-screenshot-compact">

  ![Then click create credential within environment](./assets/then-click-create-credential-within-environment.png)

  </div>

- Select Auth0 as Service
- Then configure the panel as follows

  <div class="docs-screenshot-compact">

  ![Then configure panel follows](./assets/then-configure-panel-follows.png)

  </div>

- Click `Create`. The integration to Auth0 is configured.
