This example uses @vitejs/plugin-react with Vite.
-
Copy the example environment file and fill in your Yoto API credentials:
cp .env.example .env
Then edit
.envwith your Client ID:VITE_CLIENT_ID=your_client_id_hereNote: This app uses PKCE (Proof Key for Code Exchange) for security, so no client secret is needed!
-
In your Yoto application settings in the dashboard, add this allowed callback URL:
http://localhost:3000 -
This example requests these scopes during login:
openid family:library:view user:content:viewAdd
offline_accessonly if that scope has been pre-approved for your client. -
Install dependencies:
npm install
-
Start the development server:
npm start
This app implements a secure, persistent authentication flow:
- Uses PKCE (Proof Key for Code Exchange) for the first login
- No client secret required - more secure for client-side apps
- Gets both access token and refresh token
- Uses refresh tokens for subsequent logins
- Automatically refreshes expired access tokens
- Only redirects to login when refresh token is invalid/expired
- PKCE for initial authentication (no client secret exposure)
- Automatic token refresh
- Secure token storage in localStorage
- Proper error handling and logout functionality
/- Authentication check and redirect/login- Login page with PKCE flow/app- Main application (requires authentication)