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 locally with the CLI:
appwrite run functions --function-id <FUNCTION_ID> --user-id <USER_ID>
The function runs correctly, but the impersonation headers are not generated.
Inside the function I logged the headers and I'm getting:
log(JSON.stringify({
userId: req.headers['x-appwrite-user-id'] ?? null,
hasUserJwt: Boolean(req.headers['x-appwrite-user-jwt']),
hasApiKey: Boolean(req.headers['x-appwrite-key']),
}, null, 2));
So:
{
"userId": "6978b6b8003822478082",
"hasUserJwt": false,
"hasApiKey": false
}
The CLI prints the following warning:
Dynamic API key not generated. Header x-appwrite-key will not be set.
Reason: <email> (role: users) missing scopes (["users.read"])
However the function does have the required scopes in appwrite.config.json, including:
"scopes": [
"users.read"
]
Other CLI commands work normally:
appwrite push functions
appwrite pull
deployments etc.
So the CLI login seems valid.
Am I missing something in my setup, or is there any additional configuration required for local user impersonation on self-hosted Appwrite?