auth

Types from PocketBase's Go package auth, as JavaScript sees them: you get these objects from $app and the other globals and from hook events, and call their methods by their JS names (Go's FindRecordById is findRecordById). The same package in Go: auth.

auth.Provider

Member Type
logo() (): string
order() (): number
context() (): context.Context Context returns the context associated with the provider (if any).
setContext() (ctx: context.Context): void SetContext assigns the specified context to the current provider.
pkce() (): boolean PKCE indicates whether the provider can use the PKCE flow.
setPKCE() (enable: boolean): void SetPKCE toggles the state whether the provider can use the PKCE flow or not.
displayName() (): string DisplayName usually returns provider name as it is officially written and it could be used directly in the UI.
setDisplayName() (displayName: string): void SetDisplayName sets the provider's display name.
scopes() (): Array<string> Scopes returns the provider access permissions that will be requested.
setScopes() (scopes: Array<string>): void SetScopes sets the provider access permissions that will be requested later.
clientId() (): string ClientId returns the provider client's app ID.
setClientId() (clientId: string): void SetClientId sets the provider client's ID.
clientSecret() (): string ClientSecret returns the provider client's app secret.
setClientSecret() (secret: string): void SetClientSecret sets the provider client's app secret.
redirectURL() (): string RedirectURL returns the end address to redirect the user going through the OAuth flow.
setRedirectURL() (url: string): void SetRedirectURL sets the provider's RedirectURL.
authURL() (): string AuthURL returns the provider's authorization service url.
setAuthURL() (url: string): void SetAuthURL sets the provider's AuthURL.
tokenURL() (): string TokenURL returns the provider's token exchange service url.
setTokenURL() (url: string): void SetTokenURL sets the provider's TokenURL.
userInfoURL() (): string UserInfoURL returns the provider's user info api url.
setUserInfoURL() (url: string): void SetUserInfoURL sets the provider's UserInfoURL.
extra() (): { [key: string]: any } Extra returns a shallow copy of any custom config data that the provider may need.
setExtra() (data: { [key: string]: any }): void SetExtra updates the provider's custom config data.
client() (token: oauth2.Token): (any) Client returns an http client using the provided token.
buildAuthURL() (state: string, ...opts: oauth2.AuthCodeOption[]): string BuildAuthURL returns a URL to the provider's consent page that asks for permissions for the required scopes explicitly.
fetchToken() (code: string, ...opts: oauth2.AuthCodeOption[]): (oauth2.Token) FetchToken converts an authorization code to token.
fetchRawUserInfo() (token: oauth2.Token): string|Array<number> FetchRawUserInfo requests and marshalizes into result the the OAuth user api response.
fetchAuthUser() (token: oauth2.Token): (AuthUser) FetchAuthUser is similar to FetchRawUserInfo, but normalizes and marshalizes the user api response into a standardized AuthUser struct.

auth.AuthUser

AuthUser defines a standardized OAuth2 user data structure.

Member Type
expiry types.DateTime
rawUser { [key: string]: any }
id string
name string
username string
avatarURL string
accessToken string
refreshToken string
email string The VERIFIED OAuth2 account email.
avatarUrl string
marshalJSON() (): string|Array<number> MarshalJSON implements the json.marshaler interface.