Authentication¶
Authentication¶
The API uses OAuth 2.0 Client Credentials. You will need a CLIENT_ID and CLIENT_SECRET.
The generated access token must be included in every request to the Search API.
The access token is valid for 2 hours. Clients should reuse the same token for multiple requests until it expires, rather than requesting a new token for each call. When the token expires, request a new one using the same client credentials.
Token Endpoint¶
POST https://api.ae.pex.com/oauth2/token
Authentication Method¶
- Auth: HTTP Basic Auth
- Body:
grant_type=client_credentials
Examples¶
import requests
CLIENT_ID = "YOUR_CLIENT_ID"
CLIENT_SECRET = "YOUR_CLIENT_SECRET"
response = requests.post(
"https://api.ae.pex.com/oauth2/token",
auth=(CLIENT_ID, CLIENT_SECRET),
data={
"grant_type": "client_credentials",
},
)
response.raise_for_status()
access_token = response.json()["access_token"]
print(access_token)
CLIENT_ID="YOUR_CLIENT_ID"
CLIENT_SECRET="YOUR_CLIENT_SECRET"
ACCESS_TOKEN=$(curl -s -u "${CLIENT_ID}:${CLIENT_SECRET}" -d "grant_type=client_credentials" "https://api.ae.pex.com/oauth2/token" | jq -r '.access_token')
echo "${ACCESS_TOKEN}"
Response¶
A successful authentication request returns an OAuth access token.
{
"access_token": "example_access_token",
"token_type": "Bearer",
"expires_in": 7200
}