Hi guys, I want to restrict the execution access to a function I have created to a team and to a user. I have read other posts on this suggesting that setting the async flag to false may help but it didn't in my case:
session.then(function (response) {
console.log(response); // Success
const functions = new Functions(client);
const promise = functions.createExecution('64e459b015c232d2e51d',undefined, false);
promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});
}, function (error) {
console.log(error); // Failure
});
Based on the errors, it seems like Appwrite only accepts "any" and "guests" for Execute Access:
AppwriteException: Missing "execute" permission for role "user:007". Only "["any","guests"]" scopes are allowed and "["users","user:007"]" was given.
at Client.<anonymous> (file:///D:/repo/test_appwrite/node_modules/appwrite/dist/esm/sdk.js:391:27)
at Generator.next (<anonymous>)
at fulfilled (file:///D:/repo/test_appwrite/node_modules/appwrite/dist/esm/sdk.js:22:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 401,
type: 'user_unauthorized',
response: {
message: 'Missing "execute" permission for role "user:007". Only "["any","guests"]" scopes are allowed and "["users","user:007"]" was given.',
code: 401,
type: 'user_unauthorized',
version: '1.3.7'
}
}
Anything else I can try?
Are you sure you're executing the right function? The error doesn't seem to match up with the permissions
Yes, I am sure because if I change the permission to "Any" the function runs OK:
{
'$id': '64e5687e0f089f7fd1f2',
'$createdAt': '2023-08-23T02:01:34.061+00:00',
'$updatedAt': '2023-08-23T02:01:39.458+00:00',
'$permissions': [],
functionId: '64e459b015c232d2e51d',
trigger: 'http',
status: 'completed',
statusCode: 200,
response: '{"areDevelopersAwesome":true,"thisIsNew":true}',
stdout: '',
stderr: '',
duration: 0.11366391181945801
}
Any idea where 007 is coming from?
Can you call account.get() before executing the function to see what the output is?
'007' is the userID I manually assigned to the user.
I am closing this issue: the context was that I want to create a function that would execute "on behalf" of a user and obviously during development, I would do createsEmailSession inside the function as a start etc. and this don't seem to work inside the function. My account.get() always throws inside the function but obviously from web client code, it's OK.
Recommended threads
- TablesDB can't be used in Appwrite Funct...
I have written a function (DART) and it won't deploy. Here is what I get : 2026-03-14T17:09:41.459693680Z Compiling ... 2026-03-14T17:09:42.915619217Z ../build...
- Local appwrite run functions --user-id n...
Hi, I'm running into an issue when testing Appwrite functions locally with user impersonation. I'm using a self-hosted Appwrite instance and running functions ...
- Function domain not available
Hello, even tho in docs you clearly describe that every function has its domain, I can not see it anywhere in any of my projects. How do I reveal the url of th...