I am trying to explore the node sdk for appwrite. I couldn't able to create user. Whenever I try to create user or to write in db. I am getting this error User (role: guests).
import * as env from "dotenv";
import {
  Client,
  Users,
  Account,
  Databases,
  ID,
  Permission,
  Role,
} from "node-appwrite";
env.config();
const client = new Client();
client
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject(process.env.PROJECT_ID)
  .setKey(process.env.API_KEY).setSelfSigned(true);
const users = new Users(client);
const dbs = new Databases(client);
async function createDB(){
    return await dbs.create(ID.unique(), "Demo Database");
}
async function createUser(email, password, name){
    return await users.create(ID.unique(), email, undefined, password, name);
}
This is my code
I have done the same thing in python sdk I worked perfectly fine!!
Did you debug process.env.PROJECT_ID and process.env.API_KEY already?
I have tried by giving the key as a string directly... Even It didn't works!!
The guests error means you're not authenticated. So, either the project id or API key is incorrect
Yes.. Either of them was incorrect.. My bad
[SOLVED] User (role: guests) missing scope (users.write)
No worries! Glad you figured it out!
Recommended threads
- Internal server Error when trying to exe...
When executing the function locally it works fine, but when the function is deployed I get this error: ```requests.exceptions.HTTPError: 500 Server Error: Inter...
 - Dynamic Roles
I tried to store a row with this permissions: permissions.push( Permission.read(Role.users("verified")), Permission.write(Role.label(`c-${calend...
 - appwrite auth problem regarding the sess...
Hi, I have problem with auth. When I try to login/signup using OTP, at the end session.secret is empty, i have searched online and in the docs but i cannot find...