> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Import M2M clients from Auth0

> Migrating M2M clients from other platforms like Auth0 to Stytch.

Stytch's M2M Authentication supports importing clients from other platforms like Auth0. Use Stytch to import pre-existing `client_id`s, `client_secret`s, and assigned `scopes` without any data transformations or downtime.

## Before you start

In order to complete this guide, you'll need the following:

* A Stytch project. If you don't have one already, in the [Dashboard](https://stytch.com/dashboard), click on your existing project name in the top left corner of the Dashboard, click **Create Project**, and then select **Consumer Authentication**.
* The `project_id` and `secret` for the **Test environment** you would like to use. These values can be accessed from the **API keys** section of the Stytch Dashboard. You'll need to pass these values into the `Authorization` request header for most Stytch API calls.

## Importing M2M clients

<Steps>
  <Step title="Access your existing client">
    First, access your existing client wherever it is stored. For this guide, we'll use Auth0 as an example.

    On Auth0 and under **Applications**, select an already created M2M client.

    <img src="https://mintcdn.com/stytch-34ca0595/DwZBJa3bbAb4cQs6/images/consumer-auth/authentication/m2m/m2m-auth0-client.png?fit=max&auto=format&n=DwZBJa3bbAb4cQs6&q=85&s=663bd58a07f0aa87697e086db33b5afa" alt="Auth0 client" width="2714" height="1578" data-path="images/consumer-auth/authentication/m2m/m2m-auth0-client.png" />

    You'll need to find and copy the client's values that correspond to the following Stytch M2M Client fields:

    * `client_id`
    * `client_secret`
  </Step>

  <Step title="Import the client via API or the Dashboard UI">
    In this guide, you'll use the Dashboard UI to do the import.

    In the [Dashboard](https://stytch.com/dashboard), navigate to **M2M Clients** and then click the **Import** button. A popup modal will appear prompting you to enter the client ID and secret.

    <img src="https://mintcdn.com/stytch-34ca0595/DwZBJa3bbAb4cQs6/images/consumer-auth/authentication/m2m/m2m-import-client.png?fit=max&auto=format&n=DwZBJa3bbAb4cQs6&q=85&s=5d4757b685cee999da48a70e12c6fbfb" alt="Import client to Stytch" width="2706" height="1600" data-path="images/consumer-auth/authentication/m2m/m2m-import-client.png" />

    Enter the client's values you copied from **Step 1** and click **Import**.
  </Step>

  <Step title="Add any additional metadata">
    After the import, you can update the M2M Client with additional metadata like `client_name` and `client_description`.

    <img src="https://mintcdn.com/stytch-34ca0595/DwZBJa3bbAb4cQs6/images/consumer-auth/authentication/m2m/m2m-edit-client.png?fit=max&auto=format&n=DwZBJa3bbAb4cQs6&q=85&s=9f4cd15265ff8b9b7ad681a372cdbd43" alt="Edit M2M client" width="2706" height="1604" data-path="images/consumer-auth/authentication/m2m/m2m-edit-client.png" />

    More importantly, you can transfer any previously defined scopes during this step. In Auth0, navigate to your client's permissions and record the scopes you want to transfer.

    <img src="https://mintcdn.com/stytch-34ca0595/DwZBJa3bbAb4cQs6/images/consumer-auth/authentication/m2m/m2m-auth0-scopes.png?fit=max&auto=format&n=DwZBJa3bbAb4cQs6&q=85&s=0083a01f9a95c8c7a62ce0a7dc60907a" alt="Auth0 permissions" width="2722" height="1606" data-path="images/consumer-auth/authentication/m2m/m2m-auth0-scopes.png" />

    Then in Stytch, scroll down to the **Scopes** section of the newly imported M2M Client and click **+ Add scopes**. A popup modal will appear prompting you to type in the scopes and separate them by a single space.

    <img src="https://mintcdn.com/stytch-34ca0595/DwZBJa3bbAb4cQs6/images/consumer-auth/authentication/m2m/m2m-import-scopes.png?fit=max&auto=format&n=DwZBJa3bbAb4cQs6&q=85&s=2e9d067763ff2807b5d8a2ed859d6fee" alt="Import scopes" width="2708" height="1602" data-path="images/consumer-auth/authentication/m2m/m2m-import-scopes.png" />

    Click **Save** when you've finished editing the M2M Client.
  </Step>

  <Step title="Validate the access token's payload">
    To confirm a successful import, issue an access token for the M2M Client and decode the JWT.

    ```javascript theme={null}
    {
      "aud": [
        "${projectId}"
      ],
      "exp": 1693492107,
      "iat": 1693488507,
      "iss": "stytch.com/${projectId}",
      "nbf": 1693488507,
      "scope": "read:users update:users",
      "sub": "lJJsWpAmd42q0EEJHJoSAxTPzdgpzF0i"
    }
    ```

    The access token's payload and standard claims should show the following data:

    * The `iss` and `sub` match or contain your `project_id`.
    * The `scope` matches the scopes you entered in **Step 3**.
    * The `sub` matches the `client_id` you imported from **Steps 1 and 2**.

    If the criteria are met, your M2M Client has successfully been imported to Stytch.
  </Step>
</Steps>
