Skip to main content

Interface: IAuthService

Defined in: src/types/services.ts:27

Authentication service injected into the runtime.

Remarks​

Replaces useAuthContext() from @picsart/growth-rc.

Methods​

getHeaders()​

getHeaders(): Record<string, string>

Defined in: src/types/services.ts:29

Get current auth headers (e.g., Authorization: Bearer ...)

Returns​

Record<string, string>


getRefreshedHeaders()​

getRefreshedHeaders(): Promise<Record<string, string>>

Defined in: src/types/services.ts:43

Get refreshed auth headers (re-fetches token if needed).

Must reject when the refresh yields no token (e.g. a signed-out visitor) — with RefreshTokenLoggedOutError from @picsart/runtime/client, so the miniapp settles the refresh as logged-out instead of an error (client SDK ≥ 15.15.3; older SDKs reject with the message). The miniapp SDK records a refresh failure, and stops refreshing on later 401s, only when this rejects; any resolved value — even {} or an empty Bearer — counts as a successful refresh.

Returns​

Promise<Record<string, string>>


getStatus()​

getStatus(): IAuthStatus

Defined in: src/types/services.ts:46

Get current auth status

Returns​

IAuthStatus


getUser()?​

optional getUser(): { accountType?: string; created?: string; id?: number; isNew?: boolean; key?: string; registered?: boolean; username?: string; verifiedType?: string; } | null

Defined in: src/types/services.ts:64

Get current user info

Returns​

{ accountType?: string; created?: string; id?: number; isNew?: boolean; key?: string; registered?: boolean; username?: string; verifiedType?: string; } | null


onRedirect()​

onRedirect(payload?): void

Defined in: src/types/services.ts:61

Open the host's login flow (modal on cookie-SSO hosts, full-page auth-service redirect on SSO-PKCE hosts).

Only for explicit login requests (the miniapp's openAuthScreen). Never wire it to the platform SDK's onAuthRedirect loader option — that hook fires while the SDK is navigating to a miniapp-requested external OAuth provider, and a login redirect started there cancels the provider navigation.

Parameters​

payload?​

IOpenAuthScreenPayload

The miniapp's openAuthScreen payload, forwarded as-is. Optional so existing implementations that ignore it keep working.

Returns​

void


signout()?​

optional signout(): void

Defined in: src/types/services.ts:67

Sign out the current user and clear the session

Returns​

void