
I am trying to access my collections from a node.js server runtime with the 'node-apwrite' serve sdk.
I am getting the following error: /Users/agency/Documents/website/testing/node_modules/node-appwrite/lib/client.js:174 throw new AppwriteException(error.response.data.message, error.response.status, error.response.data.type, error.response.data); ^
AppwriteException [Error]: The current user is not authorized to perform the requested action. at Client.call (/Users/agency/Documents/website/testing/node_modules/node-appwrite/lib/client.js:174:31) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Databases.createDocument (/Users/agency/Documents/website/testing/node_modules/node-appwrite/lib/services/databases.js:1691:16) at async createOtpToken (file:///Users/agency/Documents/website/testing/app.js:19:27) at async file:///Users/agency/Documents/website/testing/app.js:77:13 { code: 401, type: 'user_unauthorized', response: { message: 'The current user is not authorized to perform the requested action.', code: 401, type: 'user_unauthorized', version: '0.11.13' } }
Node.js v20.7.0
This is how I initialized the sdk: //Imports import * as sdk from 'node-appwrite' import { ID, Query } from "node-appwrite";
//AppWrite connection export const appwriteClient = new sdk.Client() .setEndpoint('https://cloud.appwrite.io/v1') .setProject('64fa13dd0e53cf8ad7e0') .setKey('c28260ba0463955d924274bdcfcf4967e06ecd360b48ae8d9afc16cd7bb65eb0c02a43211900e58a7e8e50c28928e486535c5c85e0dd5212ac033d4aacf9023a7e5575a44d5f44918dde954e013ecdbd2c99821c36f2aa05123e6f160fd7cf8ce192b0d0003abdcf31364c7e79450880b6616c81c2af0c845ec6d7a03730d7f0')
//Init AppWrite databases export const appwriteDatabase = new sdk.Databases(appwriteClient)

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

maybe the api key or project id is incorrect or the api key doesn't have enough scopes

Related issue: https://github.com/appwrite/appwrite/issues/6975

Also, you have a stack trace...what line is it throwing on exactly?
And does your collection have relationships?
Recommended threads
- Login without email or phone number
I'm making a web app targeted towards users who are very tech illiterate, so a lot of them won't even have emails. I know that the only two "identifiers" for a...
- Password Recovery link takes upwards of ...
Hello. I am having this issue above. Is there a way to make this faster? I created this project a while back when appwrite only supported Frankfurt servers. Wil...
- Best approach for handling users (creati...
I found out appwrite is wayy different to supabase, so i just wanted to check my approach is correct. Normally when creating user, I'd have something like a t...
