index/interfaces/LaunchpadSession.md
The app's session, as the SDK sees it.
Example
const sdk = createLaunchpadSDK({
env: 'stage',
session: {
accessToken: () => authMachine.currentToken(), // may wait for boot, refresh one about to expire
onUnauthorized: (rejected) => authMachine.recover(rejected), // fresh token to retry with, or null
},
});
Properties
Methods
accessToken()
accessToken():
Promise<string|null>
The bearer for the next launchpad-backend request, or null to send it unauthenticated.
Awaited before every request, so it may wait (for the app's boot) or refresh first.
Returns
Promise<string | null>
access token
onUnauthorized()
onUnauthorized(
rejectedToken):Promise<string|null>
A launchpad-backend request answered 401. rejectedToken is the bearer it carried (null: it
carried none). Resolve to a fresh token to retry the request once with it, or null to fail the
request with that 401. Called once per request at most.
Parameters
| Parameter | Type |
|---|---|
rejectedToken | string | null |
Returns
Promise<string | null>
on unauthorized rejected token