Back

User cannot execute function

  • 0
  • Web
  • Cloud
Matteo G
21 May, 2023, 14:18

hello all, I have a function with execution permissions attributed to "Any", but the user cannot execute it ((role: users) missing scope (functions.write)). Is there a way to solve this ?

TL;DR
User is having trouble executing a function that uses an API key with the right scopes. A recommendation is to add the `"execute": ["any"]` scope to `appwrite.json` and redeploy to local Appwrite. Switching the endpoint to `https://cloud.appwrite.io` may also fix the issue. It is mentioned that sometimes the `Execute Access` setting can be cleared from the Admin panel if a function is deployed without it. It is asked if the function should work with or without authentication, and if it is being executed by a user or a guest. It is mentioned that the function works in production but not in
Binyamin
21 May, 2023, 14:19

What endpoint you're accessing?

Matteo G
21 May, 2023, 14:20

a custom domain mapped to cloud instance

Matteo G
21 May, 2023, 14:21

seems to work in production, but broken in local dev

Binyamin
21 May, 2023, 14:23

I mean. How are you executing the function?

Binyamin
21 May, 2023, 14:23

Also whatever is a user or a guest?

Matteo G
21 May, 2023, 14:24

oh, I call createExecution from the client; user is authenticated, but should also work without authentication

Binyamin
21 May, 2023, 14:25

Agreed

Binyamin
21 May, 2023, 14:27

Sometime after deploying a function without setting Execute Access then the value will cleared from the Admin panel

Binyamin
21 May, 2023, 14:27

Can you verify that and share the code?

Matteo G
21 May, 2023, 14:41

yeah, but weird thing is it works in production. could it be a domain issue ? Seems that swithing the endpoint to https://cloud.appwrite.io seems to fix the issue in local

Binyamin
21 May, 2023, 14:42

I see

Binyamin
21 May, 2023, 14:42

And the settings and versions are the same as the cloud

Binyamin
21 May, 2023, 14:42

?

Matteo G
21 May, 2023, 14:45

yes

Binyamin
21 May, 2023, 15:13

I'll recommend to add this in your appwrite.json

TypeScript
  "execute": [
    "any"
  ],

Then redeploy to your local Appwrite

safwan
21 May, 2023, 15:13

make sure your api key has the functions.write scope

Binyamin
21 May, 2023, 15:14

I think is through a Client sdk

safwan
21 May, 2023, 15:14

yes yes, but the function itself uses an API key which needs to have the right scopes

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