Before you start: register a client
OAuth requires a client ID and an exact redirect URI. Client registration is currently an operator-managed boundary; there is no public self-service registration flow documented for the hosted service.- For hosted OpenKey, request a client through TinyCloud support.
- For a self-hosted OpenKey deployment, an administrator can run this command
from the OpenKey repository with
OPENKEY_API_URLandADMIN_API_KEYconfigured:
spa or native clients. These
clients use PKCE and do not have a client secret.
Install the SDK
Popup flow
The SDK generates and stores the PKCE verifier, generates astate value,
opens the authorization page, and validates the returned state before
resolving connect().
Redirect flow and callback
Redirect mode navigates the current page, soconnect() does not resolve in
the page that starts the flow.
state, and then
exchange the code. Keep these operations in this order so an untrusted callback
cannot consume the stored PKCE verifier.
Token lifecycle
- Use
expires_infrom the token response instead of assuming a fixed access token lifetime. - Keep access tokens in memory when possible. Store refresh tokens only in protected server-side or platform credential storage.
refresh_tokenis optional. The current browser SDK requests theopenidscope, so applications must not assume that a refresh token will be issued.exchangeCode()removes its stored PKCE verifier after the exchange. Start a new authorization flow if the exchange must be retried with a new code.
@openkey/core package exposes refreshAccessToken() for a
client that has been issued a refresh token. If a refresh response includes a
new refresh token, replace the old one.
