Back

[Solved] Using Client Web SDK from Node.js backend for unit tests

  • 0
  • Web
Nomka
29 Mar, 2023, 01:14

Hey there!

Big fan of Appwrite! Have been using both the Flutter Client SDK and Node.js server SDK with no problems.

However, when I try to use the client Web SDK in Node for my unit tests, I am getting User (role: guests) missing scope (account) on subsequent Account requests even after creating a session. I've attached a short screenshot of the code.

My understanding is that the library is not correctly storing and then persisting the auth headers in the subsequent calls.

However, there's no easy way to go "under the hood" to do that.

Why isn't the client library storing my session/behaving as expected? Do I have to resort to manual HTTP call management?

Thanks!

Node.js v19.6.0 Typescript v5.0.2 appwrite v10.2.0

TL;DR
The user is experiencing an issue when using the Client Web SDK from a Node.js backend for unit tests. The error message states that the user is missing the scope "account" despite creating a session. The user suspects that the library is not correctly storing and persisting the authentication headers in subsequent calls. They are unsure why this is happening and are asking if they have to manage HTTP calls manually.
Nomka
29 Mar, 2023, 01:22

Gave this some further thought and assume since the Web SDK is meant to be in browser, the library is assuming the authentication is stored in secure cookies or local storage which my Node client isn't implementing, so this actually makes sense. I'll have to find a way to emulate browser behavior in my tests or properly mock the Appwrite requests with Nock. Thanks, feel free to close. :)

Tessa
29 Mar, 2023, 03:25

Thanks for the above comment and glad you are a fan of Appwrite 😃 I’m happy you got it figured out. I’ll go ahead and close this as requested.

Tessa
29 Mar, 2023, 03:26

[Resolved] Using Client Web SDK from Node.js backend for unit tests

Tessa
29 Mar, 2023, 03:27

[Solved] Using Client Web SDK from Node.js backend for unit tests

Nomka
29 Mar, 2023, 03:27

Thanks! @Tessa we have a surprising number of shared interests in our mutual servers :P Cheers!

Tessa
29 Mar, 2023, 03:30

Feel free to connect! <:fpepefat61:1073795058387669012>

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