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
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...
- Get team fail in appwrite function
I try to get team of a user inside appwrite function, but i get this error: `AppwriteException: User (role: guests) missing scope (teams.read)` If i try on cl...