One of the first things your application needs to do when starting up is to check if the user is authenticated. This is an important step in creating a great user experience, as it determines whether to show login screens or protected content.
Check auth with account.get()
The recommended approach for checking authentication status is to use the account.get() method when your application starts:
Missing scope error
When a user is not authenticated and you call account.get(), you might see an error message like:
User (role: guests) missing scope (account)
This error is telling you that:
The current user has the role of "guest" (unauthenticated visitor)
This guest user does not have the required permission scope to access account information
This is the expected behavior when a user is not logged in
Authentication flow
In a typical application flow:
Call account.get() when your app starts
If successful → User is authenticated → Show the main app UI
If error → User is not authenticated → Redirect to login screen
Best practices
Call account.get() early in your application lifecycle
Handle both authenticated and unauthenticated states gracefully
Show appropriate loading states while checking authentication
Implement proper error handling to avoid showing error messages to users