Back

User not authorized

  • 0
  • Databases
  • Web
tinfoilht
23 Feb, 2025, 19:47

we have a function that we are attempting to create a document

TypeScript
const { databases } = await createAdminClient();

const newTournament = await databases.createDocument(
  databaseId,
  tournamentsCollectionId,
  ID.unique(),
  tournamentData
);

we are using our admin client const createAdminClient = async () => { const client = new Client() .setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT!) .setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT!) .setKey(process.env.NEXT_APPWRITE_KEY!);

return { get account() { return new Account(client); }, get databases() { return new Databases(client); }, get storage() { return new Storage(client); }, get users() { return new Users(client); }, }; };

this should allow us to overwrite all permissions. but we are getting this error Failed to create tournament: AppwriteException: The current user is not authorized to perform the requested action.

TL;DR
Developers are experiencing authorization issues when trying to create a document using an admin client. Despite setting up the client functions properly, they are still encountering an error stating that the current user is not authorized for the action. Double-check the permissions and ensure they have the necessary access rights in place.
tinfoilht
23 Feb, 2025, 19:49

we have logged the database and client and we are not sure how we could be unauthorized to create a document. Any help to get this working would be great

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