Skip to content
Back

general_unauthorized_scope, User (role: guests) missing scope (account) (401)

  • 0
  • Flutter
  • Auth
Harsha Vardhanan
30 Dec, 2024, 03:34

I've been trying to make login and signup page for my project. I am new to appwrite as well, Whenever, I try to login with the below implementation. It always states general_unauthorized_scope, User (role: guests) missing scope (account) (401). This seems like a permission issue. But I can't find anything related to it in the appwrite console except the API key. When I use the API key using .setJWT(), It says some parts of API key is missing. What is the actual problem here? Am I wrong with this implementation? How do I fix this issue in the first place?

This is my appwrite_controllers.dart file: ``` class AppwriteService { final Client client = Client(); late final Account account; late final Databases databases; late final Storage storage;

AppwriteService() { client .setEndpoint(dotenv.env['API_ENDPOINT']!) .setProject(dotenv.env['PROJECT_NAME']!);

TypeScript
account = Account(client);
databases = Databases(client);
storage = Storage(client);

}

Future<Session?> loginEmailPassword({ required String email, required String password, }) async { try { await account.deleteSessions(); final session = await account.createEmailPasswordSession( email: email, password: password, );

TypeScript
  print('User logged in successfully: ${session.$id}');
  return session;
} on AppwriteException catch (e) {
  print('Error logging in: ${e}');
  rethrow;
}

} }

TypeScript
This is my login_screen.dart file (as attachment).
TL;DR
Developers are facing a general_unauthorized_scope issue when trying to implement login and signup pages in their project using Appwrite. The problem stems from missing scope (account) for users with the role of guests, resulting in a 401 error. The API key implementation using .setJWT() is also encountering issues due to missing parts. To resolve this problem, developers may need to adjust the user permissions or scopes in the Appwrite console. Additionally, double-check the API key implementation for accuracy and completeness.
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