• Register

OAuth2.0

Some of Pirelli APIs use Oauth2.0 protocol authorization with Client Credentials grant. This means that to successfully invoke an API you need to supply a valid authorization token as header parameter. To obtain a token you need to supply the *client_id* (your key) and *client_secret* assigned to your Application, which you should have received via e-mail. Refer to the [Register your Application](/docs/read/Register_your_Application) section for instructions on how to do so. ## General Use To obtain a token you need to make a REST call to the token endpoint (generally speaking it should be something like https://api.pirelli.com/{API_NAME}/token, but you can find the exact URI in the API Console) as follows: ``` POST /{API_NAME}/token HTTP/1.1 Host: api.pirelli.com grant_type=client_credentials client_id={CLIENT_ID} client_secret={CLIENT_SECRET} ``` The required parameters need to be in the request body and encoded with the "application/x-www-form-urlencoded" encoding algorithm as per the Oauth2 RFC. Alternatively the *client_id* and *client_secret* can be sent as username and password in the basic authentication HTTP header. A cURL request example:
curl -X POST https://api.pirelli.com/{API_NAME}/token -d "grant_type=client_credentials&client_id={CLIENT_ID}&client_secret={CLIENT_SECRET}"
A valid response looks like this: ``` { "access_token": "cb4ayjx7gxw4fnbdtny4rmtt", "token_type": "bearer" } ``` Now you can call the resource endpoints, just don't forget to include the bearer token in the *Authorization* HTTP header, like this:
curl -X GET https://api.pirelli.com/{API_NAME}/resource/you/want/to/CRUD -H "Authorization: Bearer cb4ayjx7gxw4fnbdtny4rmtt"
## Dev Portal API Console Click on the *Authorize* button. Fill both fields with your key and secret then, again, click on the *Authorize* button. Now just click on *Close*. A token has now been assigned to you and will automatically be included in every API call until you navigate away from the page. [//]: # (La seguente riga abilita le anchors automatiche ma nasconde la barra dei better docs)