Example

Using the new and improved authentication method one can build their own campaign UI.

Example SDK usage to demonstrate required effort:

  • registering a user

  • authenticating that user

  • listing quests

  • completing a quest

Backend:

const thx = new THXAPIClient({
  clientId: '<CREATE_IN_DASHBOARD>',
  clientSecret: '<CREATE_IN_DASHBOARD>',
});

const identity = await thx.identity.create();
// Identity: e7f32a71-33ea-418e-9d80-32b6bf6405f0

Front-end:

const thx = new THXIdentityClient({
  clientId: '<CREATE_IN_DASHBOARD>',
  clientSecret: '<CREATE_IN_DASHBOARD>',
});

// Authenticate a specific user using his identity code
thx.setIdentity('e7f32a71-33ea-418e-9d80-32b6bf6405f0');

// List available daily quests for your campaign 
// and get the ID of the first quest
const { daily } = await thx.quests.list();
const questId = daily[0].id;
await thx.quests.daily.entry.create(questId);

// Get campaign participation info for authenticated user 
// and show point balance
const { balance } = await thx.request.get('/v1/participants');
// Balance: 10 points

Last updated