mgPass issues three types of tokens during authentication:
Token
Purpose
Default Lifetime
Configurable
Access Token
Authorize API requests
1 hour
Per-app (access_token_ttl)
Refresh Token
Obtain new access tokens
30 days
Per-app (refresh_token_ttl)
ID Token
Identity claims (name, email, etc.)
1 hour
Same as access token
Access tokens are short-lived by design. When one expires, your application uses the refresh token to get a new pair without requiring the user to sign in again.
If a previously-used refresh token is submitted (indicating potential token theft), mgPass takes aggressive action:
All refresh tokens for that user session are revoked
All active sessions for that user are destroyed
The user must re-authenticate everywhere
Never store multiple copies of a refresh token or retry with an old token after receiving a new one. Reusing an old refresh token triggers replay detection and locks out the user.
If a refresh token is expired or revoked, fall back to silent authentication using prompt=none:
The prompt=none fallback works because mgPass may still have a valid session cookie even after your refresh token has expired. This is especially common with same-domain SSO where the session cookie was refreshed by another application.
Never store tokens in localStorage or sessionStorage. These are accessible to any JavaScript running on the page, making them vulnerable to XSS attacks. Use httpOnly cookies or in-memory storage instead.
Since SPAs cannot securely store refresh tokens in the browser, use a lightweight backend proxy:The SPA only ever sees the access token (held in memory). The refresh token lives in an httpOnly cookie managed by your backend, invisible to client-side JavaScript.
Shorter access token TTLs are more secure (less time for a stolen token to be used) but increase the frequency of refresh requests. 1 hour is a good default for most applications.