Skip to main content

Acquiring the Access Token for Triumph Intelligence APIs

Updated over a week ago

Authentication wrapper on your back end

This approach requires you to create an endpoint on one of your back-end services that will make a client authentication request to the intelligence.triumph.io authentication API, using the client credentials we create for you, and then proxy the access_token from the response back to your front end. You can then provide this access_token to the bundle.

Steps

  • Acquire your client credentials from us - the client_id and client_secret

  • Create an endpoint on your back end that will call our authentication endpoint https://intelligence.triumph.io/v1/auth/token using those credentials, and return the access_token from the response. The endpoint should be protected and require authentication in your app.

  • Provide the acquired access_token to the bundle using accessTokenProvider

Example


// On the back end service
fetch("<https://intelligence.triumph.io/v1/auth/token>", {
method: "POST",
body: qs.stringify({
"grant_type": "client_credentials",
"client_id": "your_client_id",
"client_secret": "your_client_secret",
}),
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
})
.then(resp => resp.json())
.then(resp => resp.access_token);


// On the front end
function getToken() {
return fetch("your back end auth wrapper endpoint", {
headers: {
"Authorization": YourAppToken,
}
}.then(resp => resp.json())
}

...
accessTokenProvider: () => `Bearer {getToken()}
...

Google authentication (gauth)

If your app uses google as an authentication provider you can simply pass the id_token from the google auth global object.

If you decide to use this approach, please contact us first. We will need to enable this approach first for it to work for your app.

Example

function getToken() {
return gapi
.auth2
.getAuthInstance()
.currentUser
.get()
.getAuthResponse(true)
.id_token;
}

...
accesTokenProvider: () => `Bearer {getToken()}
...

Did this answer your question?