REST APIs
Authorization
For REST APIs, you need authentication to prove that you are the Admin of your property. For that, you will send the Authorization Header as part of every API request.
Header Value
The value for the Authorization header is the string AP followed by the Base64 encoding of clientId:clientSecret. For instance, if your clientID is abcd and your clientSecret is 1234, you will send the Header Authorization: AP YWJjZDoxMjM0. This is because YWJjZDoxMjM0 is the Base64 encoding of abcd:1234
Sample Python Code to Generate Authorization Header
import os
import base64
def get_ap_credentials():
client_id = os.getenv('AP_CLIENT_ID')
client_secret = os.getenv('AP_CLIENT_SECRET')
credentials_string = '{0}:{1}'.format(client_id, client_secret)
credentials_bytes = credentials_string.encode('utf-8')
base64_bytes = base64.b64encode(credentials_bytes)
base64_string = base64_bytes.decode('utf-8')
return base64_string
ap_credentials = get_ap_credentials()
auth_header = f'AP {ap_credentials}'
Postman Collection
You can check out the APIs we have available in this Postman Collection and try running them with your own credentials
Updated on: 06/27/2023
Thank you!