API Authentication
Authenticate your API requests with the Tapjoy Offerwall API to manage campaign data and performance.
Read time 1 minuteLast updated a day ago
Requesting access
Requests are authenticated using a standard two-legged OAuth2 flow: anaccess_tokenaccess_token
Example request
The following example shows the required headers for a token request.The following example shows the same request using curl.POST /v1/oauth2/token Host: api.tapjoy.com Authorization: Basic <API Key> Accept: application/json
The following example shows how to request an access token and make an authenticated GraphQL query using Ruby.curl -H "Authorization: Basic <API Key>" -X POST https://api.tapjoy.com/v1/oauth2/token
require 'json'require 'net/https'access_token = "<OAuth Token>"query = <<~ENDquery { user { firstName }}ENDjson = JSON.dump({query: query})http = Net::HTTP.new('api.tapjoy.com', 443)http.use_ssl = truerequest = Net::HTTP::Post.new('/graphql')request['Authorization'] = "Bearer #{access_token}"request.body = jsonresponse = http.request(request)result = JSON.parse(response.body)data = result['data']errors = result['errors']
Successful response
A successful request returns a 200 status with an access token and its expiry duration in seconds.status 200 { "access_token": "token_string", "token_type": "bearer", "expires_in": 3600, "refresh_token": null }
Unsuccessful response
If the API Key is invalid or missing, the request returns a 401 status.status 401{ "error": "Unauthorized" }
Using the access token
When you have anaccess_tokenaccess_tokenaccess_tokenExample request
The following example shows the required headers for an authenticated API request.POST /v4/audiences Host: api.tapjoy.com Authorization: Bearer <token_string> Accept: application/json
Missing or invalid token response
If the access token is missing or has expired, the request returns a 401 status.status 401 { "error": "Unauthorized" }