appwrite
appwrite copied to clipboard
🐛 Bug Report: Unable to get current user session on functions using jwt
👟 Reproduction steps
import { Client} from 'node-appwrite';
const userClient = new Client();
const userAccount = new Account(userClient);
userClient.setEndpoint(FUNCTIONS_END_POINT)
.setProject(PROJECT_ID)
.setJWT(x-appwrite-user-jwt);
const currentSession = await userAccount.getSession('current');
👍 Expected behavior
getSession('current') should return the current user session that is being used.
👎 Actual Behavior
Fails with user_session_not_found error.
{"code":404,"type":"user_session_not_found","response":{"message":"The current user session could not be found."...}},
🎲 Appwrite version
Appwrite Cloud
💻 Operating system
Linux
🧱 Your Environment
1.5.5
👀 Have you spent some time to check if this issue has been raised before?
- [X] I checked and didn't find similar issue
🏢 Have you read the Code of Conduct?
- [X] I have read the Code of Conduct
@Irutom, thanks for creating this issue! 🙏 I talked with team and we want to make sure the get current session API returns the session matching the session id embedded in the JWT token.
Hi @stnguyen90 I'm interested in working on this issue. Can I work on it?
@nickaldwin, assigned! Thanks for your interest! 🙏🏼
@nickaldwin, assigned! Thanks for your interest! 🙏🏼
@stnguyen90 Thank you so much
Hi @stnguyen90, Good morning and good evening! I hope you're doing great. This is my first time contributing to Appwrite. I'm having trouble replicating the issue on my end. I've followed the setup instructions and tried the reproduction steps, but I'm still facing difficulties.
Could you please provide more details on how to access and use the Appwrite Cloud function to replicate the issue?
@nickaldwin, have you looked through these docs?
That said, you don't even need to use an Appwrite function for this. You should be able to use a client SDK to
Then, use a server SDK to set the JWT token and call Get session using "current" as the ID
@nickaldwin, have you looked through these docs?
That said, you don't even need to use an Appwrite function for this. You should be able to use a client SDK to
Then, use a server SDK to set the JWT token and call Get session using "current" as the ID
Hi @stnguyen90,
I will follow this. Thank you so much for providing the reference to replicate the issue.
Hi @stnguyen90,
I hope you're well. I wanted to ask if there is a deadline for this issue. I apologize for not submitting a PR yet; this is my first time working with Appwrite, and I am still familiarizing myself with the codebase. I am very eager to work on this issue and would appreciate it if I could have some extra time to complete it. Thank you for understanding.
@nickaldwin, the sooner the better. Please keep us updated on your progress. Otherwise, I'll need to unassign you.
Hi @stnguyen90
I will unassign myself from this issue due to upcoming commitments that will require my full attention. I apologize for any inconvenience this may cause and appreciate your understanding. It has been a pleasure contributing to Appwrite, and I look forward to contributing again in the future when my schedule allows.
Hey @stnguyen90 , I can take this up.!
@Souptik2001, assigned! Thanks for your interest! 🙏🏼
Hi @stnguyen90
I will unassign myself from this issue due to upcoming commitments that will require my full attention. I apologize for any inconvenience this may cause and appreciate your understanding. It has been a pleasure contributing to Appwrite, and I look forward to contributing again in the future when my schedule allows.
No worries at all! Feel free to come back when you find the time 👋🏼
@stnguyen90 i will come back promise
Hi @stnguyen90 I have raised a PR for this one.
I have attached the detailed approach of the solution in the PR description itself. If you suggest some other approach please let me know. 👍
Hi Guys,
Were you able to solve this?
I am using this for a game that I am creating in unity. In my scenario I am saving the session in my game and hence need to verify it when user opens my game again. Thanks