Back

Appwrite exception: User (role: guests) missing scope (account)

  • 3
  • Web
D5
5 Dec, 2023, 21:05

This is usually due to permissions. Are you using Appwrite cloud?

TL;DR
User is experiencing an exception in their Appwrite app: "User (role: guests) missing scope (account)". They have already tried clearing cookies and checking permissions. They provide their code and mention that their login page was previously working properly. Other users in the thread offer suggestions such as clearing browser cache, deleting user sessions in Appwrite console, and checking network settings. It is suggested that the issue may be related to permissions or creating new sessions. The solution is to check permissions in the document or collection being accessed and ensure that the appropriate permissions are granted.
D5
5 Dec, 2023, 21:06

And do you have set permissions in the document you're getting or collection?

D5
5 Dec, 2023, 21:07

Hello! Since this is a different issue, could you please create a different post in this <#1072905050399191082> channel? I will try to help you πŸ˜„

tuyen3962
6 Dec, 2023, 05:54

I have faced this issue and i find the reason in which user has not create session (auth) in new device so it throw this exception

Ayush
6 Dec, 2023, 06:38

It was working for me two to 3 days back, but today it's not. Any ideas how do I solve this?

tuyen3962
6 Dec, 2023, 06:58

try to create new session and check again

Ayush
6 Dec, 2023, 07:01

I did, but not working

Ayush
6 Dec, 2023, 07:01

Could it be because of I'm currently on a different network rather than the one I use at home?

Ernest
6 Dec, 2023, 08:41

Consider these suggestions:

  • Clear your browser cache (or open your app in a new private browser window) which has no cache of cookies/session data.
  • Log into your appwrite console and delete all sessions of the user you're trying to login as (console->auth->(click on user)->sessions->delete all
  • If the user needs to access any collection make sure the appropriate permissions are granted.
  • Try to login again
  • If it fails again, check the user sessions in appwrite console to be sure the session was created. This will help start you off on where the problem could be.

Just my 2 cents.

Ayush
6 Dec, 2023, 10:09

Hi Thank you for your time, I tried all the options, the sessions are being created correctly. But it's still not working

Mosh Ontong
6 Dec, 2023, 10:19

I am using flutter and I am also experiencing this error

Mosh Ontong
6 Dec, 2023, 10:20

My login page was before was working properly, This is my first time to encountered this error in my login page

Ayush
6 Dec, 2023, 10:51

Here is my code:

TypeScript
import { Account, Client } from "appwrite";
import appwriteConf from "../config/appwriteConfig";

export class AuthService {
  client = new Client();
  account;

  constructor() {
    this.client
      .setEndpoint(appwriteConf.appwriteAPI)
      .setProject(appwriteConf.appwriteProjectId);

    this.account = new Account(this.client);
  }

  async signInWithGoogle() {
    try {
      return this.account.createOAuth2Session(
        "google",
        "http://localhost:5173/register",
        "http://localhost:5173/"
      );
    } catch (error) {
      console.log(`Error while logging In: ${error}`);
    }
  }

  async getUserInfo() {
    try {
      const session = await this.account.getSession('current');
      console.log(session);
      return session;
    } catch (error) {
      console.log(`Error while Fetching user: ${error}`);
    }
  }
}

const authService = new AuthService();

export default authService;
Ernest
6 Dec, 2023, 10:58

I know you're in a stressful situation but please don't tag core

Ayush
6 Dec, 2023, 11:00

Okay okay

Ayush
6 Dec, 2023, 11:00

I'll keep this in mind

Ernest
6 Dec, 2023, 11:01

Which block throws the exception? Is it signInWithGoogle or getUserInfo? Also, can you try signing in with email and password?

Ayush
6 Dec, 2023, 11:02

getUserInfo

Ernest
6 Dec, 2023, 11:07

Okay

Ernest
6 Dec, 2023, 11:10

Is 'current' your session id? Can you first try to list all sessions. Then pass the first session id into account.getSession?

Drake
6 Dec, 2023, 11:18

Please create a separate post instead of using someone else's thread

bosichelstiel
6 Dec, 2023, 14:39

Sorry, just seeing your response. Yes, I'm using appwrite cloud. And my permissions are set in collection

Drake
6 Dec, 2023, 17:31

Would you please try clearing your cookies?

bosichelstiel
6 Dec, 2023, 19:04

That fixed it, thank you!!

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