Skip to content

Checking auth status

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:

  1. The current user has the role of "guest" (unauthenticated visitor)

  2. This guest user does not have the required permission scope to access account information

  3. This is the expected behavior when a user is not logged in

Authentication flow

In a typical application flow:

  1. Call account.get() when your app starts

  2. If successful → User is authenticated → Show the main app UI

  3. 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