The problem
A code page calls the Quickbase RESTful API with a user token pasted into the JavaScript. It works, but anyone with access to the app can read the code page source and copy that token. If it belongs to an admin, they now have admin API access.
The fix: temporary tokens
The RESTful API can issue a temporary token for the person who is already signed in, scoped to an app or table. It expires after 5 minutes, so there’s nothing long-lived to steal, and every call runs with that user’s own permissions.
const REALM = 'yourcompany.quickbase.com';
async function getTempToken(dbid) {
const res = await fetch(`https://api.quickbase.com/v1/auth/temporary/${dbid}`, {
method: 'GET',
credentials: 'include', // uses the signed-in user's Quickbase session
headers: {
'QB-Realm-Hostname': REALM,
// 'QB-App-Token': '...', // only if the app requires application tokens
},
});
if (!res.ok) throw new Error(`Temp token failed: ${res.status}`);
return (await res.json()).temporaryAuthorization;
}
async function queryRecords(tableId, body) {
const token = await getTempToken(tableId);
const res = await fetch('https://api.quickbase.com/v1/records/query', {
method: 'POST',
headers: {
'QB-Realm-Hostname': REALM,
'Authorization': `QB-TEMP-TOKEN ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ from: tableId, ...body }),
});
return res.json();
}
Gotchas
- The prefix is
QB-TEMP-TOKEN, notQB-USER-TOKEN. - Request the token for the table you’re querying. Builders often report that a token requested for the app ID is refused for table-level calls, while one requested for the table works.
- Tokens expire after 5 minutes. Request a fresh one per action, or refresh before it expires, for pages that stay open.
- Permissions follow the user. That’s the point: the page can only do what the signed-in user is allowed to do.
Sending a token to an outside tool
If a button needs to hand off to your own service, formula URL and rich text fields can be set to POST a temporary token when clicked. Your service receives it as a TempToken body parameter and acts on behalf of that user, with nothing stored.
How to prevent it
Treat any token in client-side code as public. Long-lived user tokens belong only on servers, in a secrets manager.