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
- [Regression] Appwrite 25.1.0 returns Inv...
I've already opened an issue on GitHub, but somewhat it doesn't seem like GitHub is monitored very closely, so I'm leaving a bug report here on Discord as well....
- Helping in unblock my account
I deleted my Appwrite Cloud account that was linked via GitHub. Now I activated my GitHub Student Pack and want to sign up again using the same GitHub account, ...
- Not allowed permission to upsert a prese...
```js const presenceID = ID.unique(); setPID(presenceID); const presence = await presences.upsert({ presenceId: presenceID, status: "online"...