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 in the company.
- The token mustn't be revoked. For more information, see Token lifetime.
To start working with the Track & Trace API, get an OAuth token:
- If necessary, create an account in Yandex ID. When registering, use a corporate or any other email address on Yandex Mail.
- Log in to Yandex with the account you will use to upload data.
- Open the Create app page in Oauth for Yandex ID.
- In the General section, 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.
- In the Platforms section:
- Select Web services.
Place the cursor in the Redirect URI field that appears and paste the address
https://oauth.yandex.com/verification_codeor click Enter URL for debugging in the popup.
In the Data access section, enter
courier:logisticianand select Logistics Coordinator role - Load courier and order information, export results.
At the bottom of the page, click Create app.
This opens the application page. You'll need the app ID from the ClientID field to get an OAuth token.
- Get the OAuth token. To do this:
- Open the link. Enter the value obtained in step 7 in the
- Make sure the service prompts you to log in under the correct username.
- Click Log in as <username>.
- Copy the string that appears on the screen: this is your OAuth token.
Make sure the token works. To do this, add it to the request header:
curl -H "Authorization: Auth <your-OAuth-token>" -X GET https://courier.yandex.ru/api/v1/testCopied to clipboard
The response should be:
For more information about OAuth, see OAuth implementation in Yandex.
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.
- The user changes the password to the account the token was issued for.
- The user of the account the token was issued for clicks Log out of all Yandex services.
- unauthorized_client error when receiving an OAuth token
The error occurs when receiving an OAuth token (point 8.1) if there are restrictions for your account. In this case, contact support via the form. Support will check whether the restrictions can be removed and write back.Note.
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.