oauth2

Types from the Go package oauth2 (a library PocketBase builds on), as JavaScript sees them: they turn up as values of PocketBase's types and of hook events.

oauth2.AuthCodeOption

An AuthCodeOption is passed to Config.AuthCodeURL.

oauth2.Token

Token represents the credentials used to authorize the requests to access protected resources on the OAuth 2.0 provider's backend.

Most users of this package should not access fields of Token directly. They're exported mostly for use by related packages implementing derivative OAuth2 flows.

Member Type
accessToken string AccessToken is the token that authorizes and authenticates the requests.
tokenType string TokenType is the type of token. The Type method returns either this or "Bearer", the default.
refreshToken string RefreshToken is a token that's used by the application (as opposed to the user) to refresh the access token if it expires.
expiry time.Time Expiry is the optional expiration time of the access token.
expiresIn number ExpiresIn is the OAuth2 wire format "expires_in" field, which specifies how many seconds later the token expires, relative to an unknown time base approximately around "now". It is the application's responsibility to populate Expiry from ExpiresIn when required.
type() (): string Type returns t.TokenType if non-empty, else "Bearer".
setAuthHeader() (r: http.Request): void SetAuthHeader sets the Authorization header to r using the access token in t.
withExtra() (extra: any): (Token) WithExtra returns a new Token that's a clone of t, but using the provided raw extra map. This is only intended for use by packages implementing derivative OAuth2 flows.
extra() (key: string): any Extra returns an extra field. Extra fields are key-value pairs returned by the server as part of the token retrieval response.
valid() (): boolean Valid reports whether t is non-nil, has an AccessToken, and is not expired.