In addition to creating campaigns and forecasting costs, customers must understand how to manage their security credentials. A vital JSON example for any developer is the Token Refresh request.
Since access tokens are short-lived for security purposes, mastering the refresh flow is essential for maintaining a continuous, automated connection to the API without requiring manual login credentials every 30 minutes.
Example: Refreshing an Expired Access Token
This JSON payload is sent via a POST request to the token refresh endpoint. It allows the Demand-Side Platform (DSP) to trade its long-lived refresh token for a brand-new access token.
Endpoint: POST https://api.dooh.one/api/v2/login/token/refresh/
Request Body:
{
"refresh": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..."
}
Successful Response (200 OK):
{
"access": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.new_access_token_data..."
}
Why This Example is Important for Learning
-
Session Continuity: Access tokens in this system have a limited lifetime of 30 minutes, while refresh tokens are valid for 2 hours4. Understanding this JSON structure is the key to building robust applications that don't "break" or log out unexpectedly during a campaign launch.
Security Best Practices: By using this flow, a customer’s application only needs to handle the sensitive email and password once. For the rest of the session, it uses tokens, which is a significantly more secure method for programmatic interaction.
Automated Authentication: Developers can use this example to write an "interceptor" in their code. When an API call returns a 401 Unauthorized error because a token has expired, the script can automatically send this JSON to get a new token and retry the original request.
Role Consistency: Even when refreshing a token, the user must remember to continue passing the appropriate role (e.g.,
dsp) in thex-adexchange-roleheader to ensure the new token maintains the correct permissions for campaign management.
By learning this specific JSON interaction, customers can ensure their integration remains stable and operational 24/7 without manual intervention.
Comments
0 comments
Please sign in to leave a comment.