What should be passed to setSession to set user session on the server side?
- Tried setting session id retrieved from getSession() on the client side, but it failed with below error.
TypeScript
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setSession(''); // The user session to authenticate with
const account = new sdk.Account(client);
const result = await account.getSession('current');
// const result = await account.getSession('6642ddc9386a84919043');
{"code":401,"type":"general_unauthorized_scope","response":{"message":"User (role: guests) missing scope (account)","code":401,"type":"general_unauthorized_scope","version":"0.13.28"},"name":"Error","message":"User (role: guests) missing scope (account)"
- Tried setting the x-appwrite-user-jwt using setJWT on the server side and it failed with
TypeScript
client
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('5df5acd0d48c2') // Your project ID
.setJWT('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ...') // Your secret JSON Web Token
const account = new sdk.Account(client);
const result = await account.getSession('current');
{"code":404,"type":"user_session_not_found","response":{"message":"The current user session could not be found.","code":404,"type":"user_session_not_found","version":"0.13.28"},"name":"Error","message":"The current user session could not be found."
TL;DR
Developers are trying to set user sessions using the Server SDK on cloud functions.
- Passing the session ID retrieved from getSession() on the client side resulted in an authentication error due to missing scope (account). The solution is to ensure the user has the appropriate permissions.
- Setting x-appwrite-user-jwt using setJWT on the server side led to a user session not found error. The solution may involve checking if the JSON Web Token is correctly set and ensuring the user session exists.Recommended threads
- Cant get realtime working
Hey I nned some help with realtime a gain. I was using client.subscribe(...), and i found out that its depricated then i believe realtime.subscribe(...) is the ...
- Documentation That's Not Useful
Collections show me this link to explain what the activity tab is for. https://appwrite.io/docs/products/databases/databases the documentation honestly is not h...
- Hi, I'm getting this error while deployi...
✗ Error • search (6937cb70002c2e9c1a97) • Fai ✗ Error: Deployment of search has failed. Check at https://cloud.appwrite.io/console/project-693...