Skip to content
Init is here / May 19 - 23
Back

[AppwriteException: User (role: guests) missing scope (account)]

  • 0
  • React Native
  • Auth
  • Cloud
Paulito
20 May, 2025, 15:51

User signs in succesfully but after when trying to get currentuser i get the error above. It has been working for month with a user. now i implemented signup and created user getcurrentuser fails. When loggin in with the old user I encounter the same problem.

I logged the session:

Session details: {"$createdAt": "2025-05-20T14:46:01.826+00:00", "$id": "682c95a9c80fd8fd61fe", "$updatedAt": "2025-05-20T14:46:01.826+00:00", "clientCode": "", "clientEngine": "", "clientEngineVersion": "", "clientName": "OkHttp", "clientType": "library", "clientVersion": "4.12", "countryCode": "ar", "countryName": "Argentina", "current": true, "deviceBrand": "", "deviceModel": "", "deviceName": "", "expire": "2026-05-20T14:46:01.819+00:00", "ip": "181.116.201.139", "mfaUpdatedAt": "", "osCode": "AND", "osName": "Android", "osVersion": "", "provider": "email", "providerAccessToken": "", "providerAccessTokenExpiry": "", "providerRefreshToken": "", "providerUid": "paulhaas1994@gmail.com", "userId": "67d070d3001d309073d3"}

I logged the account:

{"client": {"config": {"endpoint": "https://fra.cloud.appwrite.io/v1", "endpointRealtime": "wss://fra.cloud.appwrite.io/v1", "jwt": "", "locale": "", "platform": "cuidadpasscentro.android", "project": "67d06e1f0012e210ce8b"}, "headers": {"X-Appwrite-Project": "67d06e1f0012e210ce8b", "X-Appwrite-Response-Format": "1.4.0", "x-sdk-language": "web", "x-sdk-name": "Web", "x-sdk-platform": "client", "x-sdk-version": "13.0.2"}, "realtime": {"channels": [Set], "cleanUp": [Function cleanUp], "connect": [Function connect], "createSocket": [Function createSocket], "getTimeout": [Function getTimeout], "lastMessage": undefined, "onMessage": [Function onMessage], "reconnect": true, "reconnectAttempts": 0, "socket": undefined, "subscriptions": [Map], "subscriptionsCounter": 0, "timeout": undefined, "url": ""}}}

both are not null but when performaing account.get() I get the following error:

[AppwriteException: User (role: guests) missing scope (account)]

TL;DR
Developers are encountering an error when trying to get the currently signed-in user, even after logging the session and account successfully. The issue arises due to the incorrect usage of ```createEmailSession``` instead of ```createEmailPasswordSession``` when creating sessions. The root cause is the missing account scope for users with the "guests" role, which causes the error when performing ```account.get()```. Solution: Use ```createEmailPasswordSession``` instead of ```createEmailSession``` when working with email and password logins to avoid the scope error for users with the "guests" role.
Axistro
20 May, 2025, 15:59

You are creating session via createEmailSession But you must use createEmailPasswordSession When using email and password

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