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)