Skip to content
Back

Appwrite + Google OAuth session created, but account.get() returns 401 (Role: guests)

  • 0
  • Auth
martins4
12 Sep, 2025, 11:33

Hey everyone,

I’m running into a weird issue with Appwrite’s Google OAuth provider and would love some insight.

Here’s my setup:

  • Stack: React app + Appwrite Cloud (region: FRA)
  • SDK init:
TypeScript
const client = new Client()
  .setEndpoint('https://fra.cloud.appwrite.io/v1')
  .setProject('6567777aa4758208190f');

const account = new Account(client);

Login Flow:

TypeScript
await account.createOAuth2Session(
  'google',
  'http://localhost:3000/auth/success',
  'http://localhost:3000/auth/failure'
);

The Google OAuth popup works, I get redirected back to my success URL, and in the Appwrite dashboard I can see a new active session for my user.

But as soon as I call:

TypeScript
await account.get();

I get this response:

TypeScript
{
  "message": "User (role: guests) missing scopes [\"account\"]",
  "code": 401,
  "type": "general_unauthorized_scope",
  "version": "1.8.0"
}

So it looks like the client is still considered a guest even though the session exists.

What I’ve checked so far: • The project ID and endpoint match between SDK and dashboard. • Google OAuth redirect URI is authorized in Google Cloud and matches Appwrite. • The cookie a_session_6567777aa4758208190f_legacy is present in my browser after login.

TL;DR
Developers are facing an issue where the client is considered a guest even after creating a session with Google OAuth in Appwrite. Despite a successful login flow, calling `account.get()` returns a 401 error. **Solution:** The error is due to missing scopes. To resolve this, developers should ensure that the necessary scopes (like "account") are included when creating the OAuth2 session.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more