For PIM version v4 or newer, we can follow the below steps:
- Log into your favorite PIM.
- Depending on the version you use, go to the
System/Connectionsmenu (before the v6) or theConnect/Connection settingsmenu. - Click on
Create. - Input a label for your connection,
ERPfor example. - Select a type flow.
- Click on
Save.
The Client Id , secret, user name and password will be created.
The API call to get the token:
curl -X POST http://your-host/api/oauth/v1/token
-H "Content-Type: application/json"
-H "Authorization: Basic YOUR_BASE_64_CLIENT_ID_AND_SECRET"
-d '{
"grant_type": "password",
"username": "your_API_username",
"password": "its_password"
}'
Response sample:
HTTP/1.1 200 OK
{
"access_token": "NzFiYTM4ZTEwMjcwZTcyZWIzZTA0NmY3NjE3MTIyMjM1Y2NlMmNlNWEyMTAzY2UzYmY0YWIxYmUzNTkyMDcyNQ",
"expires_in": 3600,
"token_type": "bearer",
"scope": null,
"refresh_token": "MDk2ZmIwODBkYmE3YjNjZWQ4ZTk2NTk2N2JmNjkyZDQ4NzA3YzhiZDQzMjJjODI5MmQ4ZmYxZjlkZmU1ZDNkMQ"
}
access_tokenmust be included in every request to the REST API for the client application to be authorized (see the example below).expires_inis the token lifespan (in seconds). By default, it lasts 1 hour.refresh_tokenis a special token used only to refresh youraccess_tokenafter it expired.