Back

Need help with authentication and documentation.

  • 0
  • Web
tdnshah
24 Mar, 2023, 18:52

I think API keys are used for admin purposes as far as i understood the docs, like when I want to list all the user or active session then upon requesting i was getting an error asking API key with specific scope set to it.

TL;DR
The user is seeking help with authentication and documentation in AstroJS. They mention that any JavaScript written in frontmatter is executed at build time and not shipped to the client side. They also mention a GitHub repository that might be helpful. The user recommends avoiding server-side code for simplicity and suggests using the web SDK for client-side code. They mention that import statements might not work on the client side and discuss the availability of a CDN for the SDK. The user also asks about using the JavaScript SDK on the client side in frameworks like AstroJS and clarifies the usage of API keys for admin purposes.
tdnshah
24 Mar, 2023, 18:53

Secondly, how do we use the javascript SDK on the client in frameworks like astrojs

safwan
24 Mar, 2023, 18:54

I haven't used AstroJS, so I'm not sure. But can't you use the plain JS that is provided in the docs?

tdnshah
24 Mar, 2023, 18:54

cause Import or require works only on server side if I am not wrong, so do we have a sdk available in a cdn like vue or jquery is use to provide.

tdnshah
24 Mar, 2023, 18:55

Nope I guess that is useful on Node js, it wont work in browser

safwan
24 Mar, 2023, 18:56

um is that so? I use import statements in react and next all the time!

safwan
24 Mar, 2023, 18:56

that's a different thing. There's the Server-side implementation, which is not the same as client.

tdnshah
24 Mar, 2023, 18:57

exactly and react is build using either babel, vite or webpack or snowpack, which is were it gets handled

safwan
24 Mar, 2023, 18:57

There is an SDK for nodejs, for server side integration. For JS, you should be able to use https://appwrite.io/docs/client/account

safwan
24 Mar, 2023, 18:58

yepp you're right

tdnshah
24 Mar, 2023, 18:58

On a plain js which loads on the client side wont work with this import or require syntax wont work

safwan
24 Mar, 2023, 18:59
Drake
24 Mar, 2023, 19:00

API keys should only be used server-side because they need to be kept secret. You can use a server SDK like the node one for server-side code.

Drake
24 Mar, 2023, 19:00

client side, you should use the web sdk. import it whatever way works for you

safwan
24 Mar, 2023, 19:00

exactly what I was thinking

safwan
24 Mar, 2023, 19:01

I've never had any issues using import statements in JS frameworks, and Astro should be able to handle that as well

tdnshah
24 Mar, 2023, 19:02

I guess astro is little different when it comes to the client side code

tdnshah
24 Mar, 2023, 19:03

ill learn on this an get back here

tdnshah
24 Mar, 2023, 19:03

thanks for all your support @Steven and @safwan

safwan
24 Mar, 2023, 19:04

Seems like it should do what I described

safwan
24 Mar, 2023, 19:04

But you're the astro user here, not me. Try and lmk

Drake
24 Mar, 2023, 19:04

my only recommendation is avoid server-side code if possible. it always makes things more complicated.

Drake
24 Mar, 2023, 19:06
tdnshah
24 Mar, 2023, 19:15

exactly as shown here, any javascript that is written in frontmatter (i.e between --- --- ) is executed at the build time and as claimed by astrojs, it wont ship any js on the client side which is the differentiatro of astro js hence if you still need to push any js on the client side then it needs to be added in the <script></script> tags at the end of the astro component, which is shipped to client side to be specific its called inline js

tdnshah
24 Mar, 2023, 19:16

Hope I was clear enough to explain.

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