Docs
Skip to content

Auth

Checking auth status_

Learn how to check a user's authentication status in your Appwrite application and handle authentication flow appropriately.

2 min read

Raw

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:

Plain text
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

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

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.