No, I'm using a client sdk. As an individual user.
Okay, I think I can spot the issue
When you're running the account.createEmailSession
action the returned cookie are not being sent back in the results.
I used this same api in an application using react, and when I created the user session, via email, it automatically saved the cookie in the browser, in a way that I still don't understand well (I'm a beginner).
I'm using insomnia to simulate this login, similarly to what I did in react, however I believe that the return data should be the cookie. Only it is not returned.
You can see here at
\appwrite\src\client.ts
That you never getting back the Cookies
you just get the json
And the only you will have those cookies is if you do it in window mode
Otherwise you can use the REST option with JWT
In browser it will work
But in your code you can see that the client is node
let me watch it calmly one moment
My suggestion for a quick way around it is it just to add request to get a JWT and send it back with the results, and from then you can connect using the JWT
const result = await account.createEmailSession(email, password);
const jwt = await account.createJWT();
return response.status(201).json({
message: "...",
data : {result, jwt}
});
I'm trying to understand what you're trying to say. What do you mean I would only get the cookie back in window mode? In case, I know that in the browser, somehow the cookie is saved and it works. But for me to test on my backend I would need to have a JWT, is that it? Is there a problem with insomnia requests? I had not tested with postman.
Sorry for the delay, I have difficulties with the English language.
It's bit complex issue But every time you do a request and cookies are returned they are saved inside a Cookie Jar When you running this action inside the browser or any other API tester it will take care of the Jar
But, in your situation is not insomnia
issue but the node-fetch one where the account
functions running on
So when insomnia contacting your endpoint aka create_email_session
it have all the cookies, but when your NodeJS app is contacting your AppWrite engine it does that using node-fetch and is not saving the Cookies inside the Jar
Can you show me your node package.json
?
Hum, ok. I´ĺl try.
a little complex for me still.
for sure.
Every instance can store the cookies inside the jar and provide them when there is a new request but not the node fetch in your case
And I don't think you can have a way around it without JWT
I understand. I'll test with JWT, I hadn't thought of that context. In case, if someone consumes my custom api, in the browser, it wouldn't need to access via JWT, would it? The JWT would just be for me to test as an authenticated user, right?
No
The JWT and all the app data is inside your express
code and is not exposed unless you send it somehow
ok, my friend.
👍
Thank you for your support!
You could try to manually make the API call using fetch or a axios and checking the response headers for the cookie
Recommended threads
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- apple exchange code to token
hello guys, im new here 🙂 I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...
- How to Avoid Double Requests in function...
I'm currently using Appwrite's `functions.createExecution` in my project. I want to avoid double requests when multiple actions (like searching or pagination) a...