Webview Authentication
MentraOS provides a simple and secure way for apps to identify users within webviews. When a user opens your web application through the MentraOS Mobile App, you can automatically identify them without requiring a separate login process.What Is Webview Authentication?
Webview authentication lets your web application identify MentraOS users without requiring them to log in separatelyWhen a user opens your webview through the MentraOS Mobile App:
- The manager app automatically appends a temporary authentication token to your URL
- The MentraOS SDK middleware automatically exchanges this token for the user’s ID
- Your webview can then provide a personalized experience based on the user’s identity
When a user opens your website through their browser on their phone or computer:
- You can redirect them to the MentraOS OAuth flow by redirecting them to the
/mentra-auth
endpoint. - The MentraOS OAuth flow will redirect them back to your website’s main webview url, with a token in the query parameters.
- The MentraOS SDK will automatically exchange this token for the user’s ID.
- Your webview can then provide a personalized experience based on the user’s identity.
How It Works
1. Include a Webview in Your App
First, specify a webview URL in your app’s configuration through the MentraOS Developer Console:- Log in to the MentraOS Developer Console
- Navigate to your app’s settings
- Add your
Webview URL
- Save your changes
2. Set Up Authentication with the SDK
The MentraOS SDK provides built-in middleware that handles the token exchange process automatically:3. Access User ID in Your Routes
In your Express route handlers, access the authenticated user ID:4. Redirect to the MentraOS OAuth flow if the user isn’t logged in automatically
If the user isn’t logged in automatically, you can redirect them to the MentraOS OAuth flow by redirecting them to the/mentra-auth
endpoint.

https://account.mentra.glass/sign-in-mentra.png
Common Use Cases
Webview authentication enables:- Personalized dashboards and content
- User-specific settings and preferences
- Integration with your existing user database
- Seamless experiences without additional login steps