Back

createToken erroring on new user ID?

  • 0
  • Auth
  • Cloud
ZachHandley
15 May, 2024, 18:18

Hey, as far as I understand it createToken e.g. users.createToken is to create a new user, but it seems like it's just searching for a user?

TypeScript
 const userId = ID.unique();
      console.log("Creating user with ID:", userId);
      const user = await this.users.createToken(userId);
      console.log("User created successfully:", user);

is throwing an error

TypeScript
Creating user with ID: 6644fbfd003a3e4bf111
Error creating user: AppwriteException [Error]: User with the requested ID could not be found.
    at Client.call (/home/zach/GitHub/rev3almarketplace/webserver/node_modules/node-appwrite/lib/client.js:206:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Users.createToken (/home/zach/GitHub/rev3almarketplace/webserver/node_modules/node-appwrite/lib/services/users.js:1395:16)
    at async UserApi.createUserByWallet (/home/zach/GitHub/rev3almarketplace/webserver/src/server/actions/userApi.ts:176:20)
    at async Module.POST (/home/zach/GitHub/rev3almarketplace/webserver/src/pages/api/auth/connect.json.ts:29:29)
    at async renderEndpoint (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/runtime/server/endpoint.js:34:20)
    at async callMiddleware (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/core/middleware/callMiddleware.js:21:10)
    at async RenderContext.render (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/core/render-context.js:148:22)
    at async handleRoute (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/vite-plugin-astro-server/route.js:209:18)
    at async run (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/vite-plugin-astro-server/request.js:40:14)
    at async runWithErrorHandling (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/vite-plugin-astro-server/controller.js:64:5)
    at async handleRequest (file:///home/zach/GitHub/rev3almarketplace/webserver/node_modules/astro/dist/vite-plugin-astro-server/request.js:34:3) {
  code: 404,
  type: 'user_not_found',
  response: {
    message: 'User with the requested ID could not be found.',
    code: 404,
    type: 'user_not_found',
    version: '0.13.24'
  }
}

Is this due to lack of access via my API key?

TL;DR
Support thread discussing issues with the `createToken` method, believed to create a new user but actually functions to create an access token. Code snippet provided showing error message "User with the requested ID could not be found." Possible cause suggested as lack of access via API key. Solution: `createToken` does not create new users; investigate further for user creation.
ZachHandley
15 May, 2024, 18:21

no, not due to lack of access

Steven
15 May, 2024, 18:41

create token creates like an access token/session

Steven
15 May, 2024, 18:42

docs are wrong. it doesn't create a user. can you create a github issue for that?

ZachHandley
15 May, 2024, 18:57

yessir

ZachHandley
15 May, 2024, 18:58
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more