Using the Token
Using the Tokenlink
All Personal Access Tokens (PATs) are associated to a "System" user under your Infraspeak account. This means that by using a PAT you are communicating with Infraspeak REST API on behalf of the client. Actions executed over an API resource that stores action history will be displayed on the web interface as "<API user name> ...(action performed)". E.g.: "Integration ACME created the Work Order".
Authorization Headerlink
All API requests must include the token in the Authorization header using the Bearer scheme:
Authorization: Bearer YOUR_TOKEN
Important: The word "Bearer" is required before the token, followed by a single space. Make sure there are no spaces or blank lines at the end.
Verifying Your Tokenlink
Test your token to check it is working:
curl -X GET "https://api.infraspeak.com/v3/locations?limit=1" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json"
Expected Responselink
A successful verification returns a JSON similar to this:
{
"data": [
{
"id": "12345",
"type": "locations",
"attributes": {
"name": "Main Building",
"code": "MB-001"
...
}
}
],
"meta": {
"pagination": {
"total": 1,
"count": 1,
"per_page": 1,
"current_page": 1,
"total_pages": 1
}
}
}
Common Mistakeslink
"Authentication token invalid"link
- Token was not copied completely (part of the token is missing)
- Token contains extra whitespace
- Using production token in sandbox (or vice versa)
Missing "Bearer" Prefixlink
# Wrong - missing Bearer
curl -H "Authorization: YOUR_TOKEN" ...
# Correct
curl -H "Authorization: Bearer YOUR_TOKEN" ...
Extra Whitespacelink
# Wrong - extra spaces
curl -H "Authorization: Bearer YOUR_TOKEN " ...
# Correct - single spaces, and no new line/space at the end
curl -H "Authorization: Bearer YOUR_TOKEN" ...