Okay, from what I'm seeing it uses client side SDK but passes cookies to server side to avoid conflict so a part is executed client sided as I was supposing
The thing is, I don't mind using only Rest API, but the docs are kind of minimal and I have no clue how to properly implement the auth using just rest api. I understand fetching and everything, but what data do I store? do i store it as localstorage like the client sdk? and what does the key/value need to be? What if I want to create a JWT?
It says just this
POST /v1/account/jwt HTTP/1.1
Host: HOSTNAME
Content-Type: application/json
X-Appwrite-Response-Format: 1.4.0
X-Appwrite-Project: 5df5acd0d48c2
But how does the rest api know who the user is? I feel like there's chunks missing
Have you read through this? https://appwrite.io/docs/apis/rest#authentication
That actually helps a lot, thanks Steven! One more question about JWT actually, why is there a legacy sometimes popping up in the cookies using the client sdk?
a_session_projectid_legacy for example
It's not consistent, it's very random on logging-in, as I think the client sdk uses localstorage instead of cookies, so it makes even less sense
The only difference is the samesite option. The legacy one doesn't specify anything for that for backwards compatiblity or something
Ah, alright
TL;DR, You should use Rest API if you use edge runtime
Hey @Steven, Do I need both cookies? Or is just the a_session_projectid enough?
The thing I don't understand, is if you got for example a cookie called a_session_projectid with the value eyJpZCI6IjY1NTI1ZW...TE3MjBiMTdjOSJ9, and I try to fetch /v1/account with that value using rest api fetched via client, it just says 401
As far as I understood it, you only need to create a JWT if you want the server to fetch for example, right?
nvm, seems I got it working!
Thanks everyone for helping with this topic! Setting it as solved.
[Solved] Window not defined | Edge runtime not supported
Yes that one should be enough
Hey how were you able to resolve the problem?
Hey. Are you using nextjs?
Yes
use rest api instead of client sdk
Can you give me kind of pseudo overview on how to use this
With the rest apiece
See reference on docs
I simply send jwt tokens along the request and authenticate that?
You set the token as a cookie with secure and httponly, you use the "Cookie" header as authentication
Thanks
Recommended threads
- education plan not activated
Hi I have an edu id 13103046@iubat.edu but when I am trying to claim my plan and trying to logging with github where education student plan active. the appwrite...
- 500 simultaneous OAuth logins from the s...
Hi, I'd like to ask about rate limiting around Google OAuth login on Appwrite Cloud. **OVERVIEW** Service type: A PWA (web app) for members of a university clu...
- Suspicious access pattern detected when ...
Hello, I am having trouble restoring my project. In the past it worked with no problems, but today I get an error "Suspicious access pattern detected". How can ...