Community Discussion

Ask a Question
Back to All

Taboola Access Token invalid 401

When I request a new access token, I always get the same access token. It never returns a new one. Even after days and this access token is invalid, except for 1 request.

All the other requests return 401

==== How I request the access token:

encodedParams.set('client_id', process.env.TABOOLA_CLIENT_ID);
encodedParams.set('client_secret', process.env.TABOOLA_CLIENT_SECRET);
encodedParams.set('grant_type', 'client_credentials');

const url = 'https://backstage.taboola.com/backstage/oauth/token';
const options = {
method: 'POST',
headers: {'content-type': 'application/x-www-form-urlencoded'},
body: encodedParams
};

==== Response I get, same token even after days

{
access_token: 'same_access_token',
token_type: 'bearer',
expires_in: 43199
}

==== Only that request is working, but it is returning old data. New campaigns aren't returned. Just adding ?fetch_level=R to the url, returns 401

const accountId = process.env.TABOOLA_ACCOUNT_ID

const accessToken = process.env.TABOOLA_ACCESS_TOKEN // I console logged this the taboola account id and the access token and they are correct

const url = https://backstage.taboola.com/backstage/api/1.0/${accountId}/campaigns/;
const options = {
method: 'GET',
headers: {
'Authorization': 'Bearer ' + accessToken,
'Content-Type': 'application/json'
}
};