Back

Can you make an authenticated user request to execute a function using its URL domain?

  • 0
  • Functions
  • Web
  • Cloud
  • REST API
MC
8 Nov, 2024, 10:38

I created an AppWrite function to use as a basic REST API. I send GET and POST requests to the function's deployed URL : asdfsarandomstringasfd.appwrite.global

It works if I set the function's execute access to Any.

However, I want it to work for authenticated requests only.

I don't want to use the .createExecution function or SDK functions as I'm using a library that handles the load and sync responses using a url.

Is this possible? I get the following error if I change the function's execute access to users, which implies that I can't:

TypeScript
Error 401

To execute function using domain, execute permissions must include "any" or "guests"

Type

`user_unauthorized`

Is it possible to make an authenticated request to the deployed function URL by just setting the correct headers? My React frontend has user authentication setup and makes requests to the URL - I can get the user details from the logged in user.

I tried to make an authenticated request using Thunder Client by setting the function execution headers - https://appwrite.io/docs/products/functions/develop#headers

However, I get a 401 Unauthorized error.

TL;DR
Developers want to make authenticated requests to execute a function using its deployed URL domain by setting the correct headers. They face a 401 Unauthorized error when they attempt this. The error indicates that execute permissions must include "any" or "guests." To resolve this, developers need to include the necessary execute permissions in their request headers or use AppWrite's `.createExecution` function.
MC
8 Nov, 2024, 10:49

Can you make an authenticated user request to execute a function using its URL domain?

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