AuthContext
AuthContext = {
type:"asApp"; } | {type:"asUser";userId?:string; } | {accessToken:string;accountId:string;type:"offlineUser"; }
Defined in: packages/core/src/adapters/ForgeAdapter.ts:19
Discriminated union describing who is making an API request.
asApp— the Forge app itself (app-scoped permissions)asUser— a live user session (the currently invoking user, or a specific userId)offlineUser— a user impersonated without a live session via a pre-fetched access token
Create auth contexts with the helper functions asApp, asUser, or asOfflineUser rather than constructing this union type directly.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ type: "asApp"; }
Type Literal
Section titled “Type Literal”{ type: "asUser"; userId?: string; }
Type Literal
Section titled “Type Literal”{ accessToken: string; accountId: string; type: "offlineUser"; }
accessToken
Section titled “accessToken”accessToken:
string
A short-lived access token for the given accountId. Obtain this via OfflineTokenManager.getToken() or ForgeRemoteTokenManager.getToken() before constructing the auth context. Token fetching is always the caller’s responsibility — the adapter uses the token as-is and never fetches one internally.
Example
Section titled “Example”const token = await tokenManager.getToken(accountId);const client = asOfflineUser(adapter, token.accountId, token.accessToken);accountId
Section titled “accountId”accountId:
string
type:
"offlineUser"