Voted Best Answer
Jan 27, 2021 - 02:54 PM
I can see how this is a little unclear.
Above the /tokens endpoint there's a button saying "Authorize", this lets you know how to authorise your requests.
The Basic type authorization is what you need to pass in as a header to the /tokens endpoint.
For all the others, you need the Bearer type authorization header and you'll use the token that you've previously obtained.
Here's an example with cURL: Getting the token using a base64 encoding of "username:password":
Then using that token to get a list of categories:
One thing of note is in the 2020_12_31 version, the casing needs to be "Bearer" and "Basic". This is resolved in later versions.
Above the /tokens endpoint there's a button saying "Authorize", this lets you know how to authorise your requests.
The Basic type authorization is what you need to pass in as a header to the /tokens endpoint.
For all the others, you need the Bearer type authorization header and you'll use the token that you've previously obtained.
Here's an example with cURL: Getting the token using a base64 encoding of "username:password":
curl -X POST "http://localhost:8224/pi/api/v2/tokens" \
-H "accept: application/json" \
-H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ="
Then using that token to get a list of categories:
curl -X GET "http://localhost:8224/pi/api/v2/categories" \
-H "accept: application/json" \
-H "response-collection-format: LIST" \
-H "Authorization: Bearer Lixeqqhojw87yj0imeniapxneo5kykalkm6pymdbts4heldprt"
One thing of note is in the 2020_12_31 version, the casing needs to be "Bearer" and "Basic". This is resolved in later versions.
Add New Comment