Skip to main content

Calling An API

All our APIs use the OAuth2 Client Credentials Grant Flow to authentication. As such, the process to call them is:

  1. Request a token from the token endpoint
  2. Call the API you want to use and pass the access token in the Authorization header as a bearer token
    • Re-use the same token between API call until it expires

API Request Example

Requesting A Token

See our section here for instructions of how to get credentials.

curl -X POST 'https://auth.pj.nu/oauth2/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Accept: application/json' \
--data 'grant_type=client_credentials' \
--data 'client_id=YOUR_CLIENT_ID' \
--data 'client_secret=YOUR_CLIENT_SECRET'

this will return a JWT token in the form of

{
"access_token": "eyJhbGciOi.....",
"expires_in": 86399,
"scope": "",
"token_type": "bearer"
}
Try it out or generate code

Try our specification section in order to get a token via the browser UI or generate code in your preferred language.

Calling An API

Use access_token from the get token request as bearer token in the Authorization header when calling our APIs

warning

Do not request a token on each API request, re-use the same token until it expires.

curl -X GET 'https://api.pj.nu/echo' \
--header 'Accept: */*' \
--header 'Authorization: Bearer ACCESS_TOKEN'