---
metadata:
  - name: generator
    content: Diplodoc Platform v5.19.6
alternate:
  - https://docs.routeq.com/doc/en/delivery/quickstart/register.md
  - https://docs.routeq.com/doc/tr/delivery/quickstart/register.md
title: RouteQ — API implementation procedure — getting an OAuth token
---
> **Documentation Index:** Fetch the complete configuration index at https://docs.routeq.com/doc/en/llms.txt


# Getting an OAuth token

To work with the Track & Trace API, you need an OAuth token. OAuth token requirements:

- The token must be created for a user who's an [administrator](https://docs.routeq.com/doc/en/delivery/interface/managers.md#user-roles) in the company.
- The token mustn't be revoked. For more information, see [Token lifetime](#lifetime).

To start working with the Track & Trace API, you must first get an OAuth token:


1. If necessary, create a [Yandex ID](https://passport.yandex.com/registration) account. When registering, use a corporate or any other email address on Yandex Mail.

2. Log in to Yandex with the account you will use to upload data.

3. Go to [Access for external apps](https://oauth.yandex.com/) and click **Create app**.

4. Select **For API access or debugging** and click **Create**.
   

5. Fill in the **Service name** field. You can enter any name. It will appear in your app list in OAuth for Yandex ID. You don't need to attach the service icon.

6. In the **Email address** field, enter your email address.

7. In the **Permission name** field, enter `courier:logistician`.

8. Click **Create app**. 

    This opens the application page. You'll need the app ID from the **ClientID** field to get an OAuth token.

    ![](./../_images/client-id.png){style="border: solid 1px #cccccc; max-width: 800px;"}

9. Get an OAuth token. To do this:
    
    1. Open the link. Paste the value obtained in Step 7 into the `<ClientID-of-your-app>` field.



       ```
       https://oauth.yandex.com/authorize?response_type=token&client_id=<ClientID-of-your-app>
       ```



    2. Make sure the service prompts you to log in under the correct username.
    3. Click **Log in as <username>**.
    4. Copy the string that appears on the screen: this is your OAuth token.
    5. Make sure the token works. To do this, add it to the request header:

    ```
    curl -H "Authorization: OAuth <your-OAuth-token>" -X GET https://courier.yandex.ru/api/v1/test
    ```

    The response should be: `{"message":"OK"}`.

    For more information about OAuth, see [OAuth implementation in Yandex](https://yandex.com/dev/id/doc/dg/oauth/concepts/ya-oauth-intro.html).



## Token lifetime {#lifetime}

Token lifetime is not limited.

The token may become invalid if:

- It has been revoked. If your token was revoked, you need to get a new one. For more information about why a token may be revoked, see [Revoke a token](https://yandex.com/dev/id/doc/en/tokens/token-invalidate).
- The user changes the password to the account the token was issued to.
- The user of the account the token was issued to clicks **Log out of all Yandex services**.


## Troubleshooting {#solving-problems}

#### unauthorized_client error when receiving an OAuth token

The error occurs when receiving an OAuth token (Step 8.1) if there are restrictions for your account. In this case, contact support via the [form](https://yandex.ru/dev/id/doc/en/feedback). Support will check whether the restrictions can be removed and write back.

{% note info %}

Before filling out the form, make sure that you're logged in under the account for which there are restrictions. Otherwise, the form won't open.

{% endnote %}

{% include [warehouse-feedback](../_includes/feedback-7b71896f9bc3.md) %}
