I'm trying to get the current user in my Appwrite function but I'm getting this error: AppwriteException: app.677c6d970016b1973c68@service.cloud.appwrite.io (role: applications) missing scope (account)
Why is that?
Here's my code:
TypeScript
const { Client, Account } = require('node-appwrite');
const { Permit } = require('permitio');
if (triggerType === 'event' && data.bucketId) {
try {
const account = new Account(client);
const user = await account.get();
await permit.api.resourceInstances.create({
resource: "file",
key: data.$id,
tenant: "default",
});
const resource_instance = `file:${data.$id}`;
await permit.api.roleAssignments.assign({
user: user?.email,
role: 'owner',
resource_instance,
});
return res.json({
ok: 'success',
message: `Resource instance created and the owner is ${user?.name}`,
});
} catch (err) {
error(err);
return res.json({
ok: 'fail',
message: `There was error adding file resource`,
});
}
}
TL;DR
Issue: Error `AppwriteException: app.677c6d970016b1973c68@service.cloud.appwrite.io (role: applications) missing scope (account)` when trying to use `account.get()` in Appwrite cloud function.
Solution: The error occurs because the user does not have the required scope. Make sure the user has the `account` scope assigned.Recommended threads
- CORS errors in Obsidian custom plugin
Hi, anyone here familiar with obsidian community plugins? In short: it's a local first note app which supports writing your own add-ons / plugin But I keep get...
- > AppwriteException: The requested servi...
When trying to read or write from my database I get the following error: > AppwriteException: The requested service is disabled. You can enable the service from...
- Courtesy limit reset for non-profit migr...
Hi Team! I'm the architect for a 501(c)(3) non-profit project (Aaria's Blue Elephant) and we just hit our Free plan Database Read limit (currently at 164%). Th...