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
- HUGE OUTRAGE IN APPWRITE, I CANNOT ACCES...
I have 2k users trying to access, sending me messages. What am I supposed to do? Please solve this asap.
- All my apps are not opening now
All my apps are not opening now 200+ apps are not opening plz fast
- My projects were deleted
Hello everyone, My projects were for some reason deleted. I got an email informing me about project inactivity, when I clicked to activate it again, it was sil...