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
- TEAM INVITE
There is a problem with the team invitation. When a user invites other users, that time, the newly created email address they don't get the invite link and old ...
- 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...