Back
[SOLVED] Cloud Function with Storage: (role: applications) missing scope (files.read)
- 0
- Functions
- Storage
Mosh Ontong
I am creating a function which I need to get a files
TypeScript
module.exports = async function (req, res) {
const client = new sdk.Client();
// You can remove services you don't use
const database = new sdk.Databases(client);
const storage = new sdk.Storage(client);
if (
!req.variables["APPWRITE_FUNCTION_ENDPOINT"] ||
!req.variables["APPWRITE_FUNCTION_API_KEY"]
) {
console.warn(
"Environment variables are not set. Function cannot use Appwrite SDK."
);
} else {
client
.setEndpoint(req.variables["APPWRITE_FUNCTION_ENDPOINT"])
.setProject(req.variables["APPWRITE_FUNCTION_PROJECT_ID"])
.setKey(req.variables["APPWRITE_FUNCTION_API_KEY"])
.setSelfSigned(true);
}
// parse json
const data = JSON.parse(req.variables["APPWRITE_FUNCTION_EVENT_DATA"]);
var file;
file = await storage.getFile(data.bucketId, data.$id);
res.json({
areDevelopersAwesome: true,
payload: file,
});
};
The error response please see the image attach:
TL;DR
The user encountered an error with their cloud function, specifically with the missing scope "files.read". Another user suggested checking if the API key has the correct scope. The code provided uses the Appwrite SDK to fetch a file from storage. However, the user did not mention a specific error message or attach an image for reference.
Solution: Add the "files.read" scope to the API key in order to resolve the error. Binyamin
Did you gave the API key the file.read scope?
Mosh Ontong
ohh I see thank you
Drake
[SOLVED] Cloud Function with Storage: (role: applications) missing scope (files.read)
Recommended threads
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- HTTP POST to function returning "No Appw...
Hi everyone, I’m running into an issue with my self-hosted Appwrite instance. I’ve set up my environment variables (APPWRITE_FUNCTION_PROJECT_ID, APPWRITE_FUNC...
- Can't add dart 3.5 runtime
Modified the `.env` to enable dart 3.5 runtime on my self-hosted instance but still can't find the runtime when creating a new function. I manually pulled the i...