Authentication - Single Page App
A high-level overview of how authentication works with a single page app.
Login
Steps:
- The user clicks the Login button on your website or application.
- The user is sent to the Login Route implemented in your SPA.
- The SPA creates an Authorization Request and redirects the user to the Wristband Authorize Endpoint.
- Wristband validates and records the Authorization Request and redirects the user to the Wristband-hosted Login page.
- The user provides their credentials to authenticate.
- The Login Page redirects to your SPA's Callback Route with an authorization code.
- The Callback function calls Wristband's Token Endpoint to exchange the authorization code for an access token.
- The Callback function stores the access token and refresh token locally in the browser.
- The user is redirected to your SPA's entry point.
Logout
Steps:
- The user clicks the Logout button within your SPA.
- The SPA invokes a
logout()
function, destroying the session and tokens stored locally in the browser. - The SPA calls the Revoke Token Endpoint to revoke the refresh token.
- The user is redirected to the Wristband Logout Endpoint.
- Wristband destroys the authentication session and redirects the user to your SPA's Login route.
Updated 2 days ago