Skip to main content

Tokens

The /v1/apps/tokens endpoint allows you to obtain a JWT access token using your application credentials.

Endpoint

POST https://targeted-api.adgem.com/v1/apps/tokens

Request

Headers

HeaderValueRequired
Content-Typeapplication/jsonYes

Body Parameters

ParameterTypeRequiredDescription
adgem_pub_idintegerYesYour AdGem publisher identifier
adgem_app_idintegerYesYour AdGem application identifier
client_idstringYesYour application's client identifier
client_secretstringYesYour application's client secret

Example Request

curl -X POST https://targeted-api.adgem.com/v1/apps/tokens \
-H "Content-Type: application/json" \
-d '{
"adgem_pub_id": 0,
"adgem_app_id": 0,
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}'

Response

Success Response (200 OK)

When the credentials are valid, the API returns a JWT access token:

{
"access_token": "<your-jwt-token>",
"token_type": "Bearer",
"expires_in": 3600
}
FieldTypeDescription
access_tokenstringThe JWT token to use in subsequent requests
token_typestringThe type of token (always Bearer)
expires_inintegerToken validity duration in seconds

Error Responses

401 Unauthorized

Returned when the provided credentials are invalid.

{
"error": "invalid_client",
"error_description": "Invalid client credentials"
}

500 Internal Server Error

Returned when an unexpected error occurs during token generation.

{
"error": "server_error",
"error_description": "An unexpected error occurred"
}

Usage

Once you have obtained the access token, include it in the Authorization header of all requests to the Targeted API:

curl -X POST https://targeted-api.adgem.com/v1/offers \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"query": "{ offers(player_id: \"user123\") { id name total_payout_usd } }"
}'

Token Lifecycle

  1. Request - Call /v1/apps/tokens with your credentials
  2. Receive - Store the access_token from the response
  3. Use - Include the token in the Authorization header
  4. Refresh - When you receive a 401 response, request a new token

See Also