I am using node-appwrite on server side to getSession of the user which I explicitly stored in cookie.
try{
await account.getSession(event.cookies.get("sessionId"));
}catch(error) {console.log(error)}
Framework being used is Sveltekit
Do you have set in the API key the corresponding scopes?
Yes I have given auth scope for the given api key in the console. I could fetch documents but not accounta
What’s the error you’re getting?
code: 401, type: 'general_unauthorized_scope', response: { message: 'app.<PROJECT_ID>@service.cloud.appwrite.io (role: applications) missing scope (account)', code: 401, type: 'general_unauthorized_scope', version: '0.12.17' } }
This is the response I got
Are you sure project ID is correct?
Yes I am sure that project ID is correct. Since I am able to fetch documents using that client on server side.
I’ve never seen this error. Hopefully someone from Core can jump in?
Is there any other way to get the session of user on server side. Consider session Id is being stored on cookie.!!!
With JWT
Just to check - what exactly is it that you’re trying to get?
But JWT has a tradeoff of getting expired after 15 min of creation. How can I create JWT upon expiration on client side??
You will need to create a net JWT once it expires. That's the issue
Why exactly is it that you’re trying to do?
I need to authenticate user on ssr. For better user experience.. when it is done on client side. It is taking a while to load user baisc info such as id,email,name
You said you’re setting the sessionID as a cookie. Could you do the same for the userID?
You can't use get session to authenticate.
I highly suggest not using SSR if possible because it's complicated.
If you really want to, you'll need to proxy the authentication through your back end and manually authenticate so you can extract the session cookie. Then, you'll need to manage the cookie yourself.
Here's a demo: https://next-js.ssr.almostapps.eu/.
That said, we do have plans to improve SSR support in the near future.
Recommended threads
- Many2Many loading, not receiving list
Hi everyone! Im having a bit of trouble while editing single rows in the DB. When selecting a value of my many2many it keeps loading, see screenshot. On some ...
- SSR Auth with Tanstack Start requires ha...
I followed the Next.js guide for SSR Auth on https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-1 I tried to replicate it for Tanstack Start. However, on...
- Cannot update relationship value with ev...
I have 2 Tables. One for all Clients (Image 3) and one for projects the clients can create. The problem: I can only assign a handful of clients (Image 1). The r...