
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
- appwrite cli alpine os
the appwrite cli does not work on alpine os if you install it using the recommended bash script. Maybe there is the possibility to compile it for alpine using t...
- Invalid document structure: Unknown attr...
I have an attribute, who I deleted but it still gives error saying that Invalid document structure: Unknown attribute: "financialAidAvailable". Because of which...
- Migration to new region: not so good.
We attempted to do a migration to NYC... and things didn't go well. We followed the steps (exactly) as shown in the video, updated our app with the new endpoint...
