
Otherwise, Im curious about the configuration of the get current session and how you're setting the headers

If I use fetch, how do I get the Fallback-Cookie?

User (role: guest) missing scope (account) via Appsmith


I used console.log(...response.headers)
to see all the headers but it only returns me with

This is from the create email session?

yes it is

What's the code and what's the network logs?


I'm pretty sure you can create async functions so you can use await and avoid the confusing then callbacks.
It looks like the cookies are set properly so no fallback header is returned...does manually calling the account get work? Does using the Appwrite SDK to call account get work?

For manual account get API call, you might need to include credentials in the options and set it to include like https://github.com/appwrite/sdk-for-web/blob/1dde5c7bc91b18bfc1f4e2a80b0ba77017db66fe/src/client.ts#L370

Its okay I'll use the callbacks because the function SubmitLogin cannot support async since its connected to a button I tried calling it manually using the API and the SDK still produces the same output

That's bizarre it doesn't work...it doesn't make sense...I'll have to play around with this myself in the morning

Okay thankyou for your quick reply

well..my server can't run mongodb so it can't run appsmith and it doesn't look like i can set a custom hostname on the cloud instance so im going to have to find another workaround

okay! so it looks like JS Object runs in a service worker and that's why the cookie isn't being returned and stored. another weird thing is localstorage works so if you try to set the header, it will be overwritten by what's in localstorage (null/empty string). soooo this is what i got working...
CreateEmailSession query with body of:
{"email":{{this.params.email}},"password": {{this.params.password}}}
Then, I have a JS Object named authService
that has:
export default {
createEmailSession: async (email, password) => {
await CreateEmailSession.run({email, password});
const fallbackCookies = CreateEmailSession.responseMeta.headers['X-Fallback-Cookies'][0];
if (typeof window !== 'undefined' && window.localStorage) {
window.localStorage.setItem('cookieFallback', fallbackCookies);
}
const client = new Appwrite.Client().setEndpoint(constants.endpoint).setProject(constants.project);
const account = new Appwrite.Account(client);
const user = await account.get();
storeValue('user', user);
},
deleteSession: async () => {
const client = new Appwrite.Client().setEndpoint(constants.endpoint).setProject(constants.project);
const account = new Appwrite.Account(client);
await account.deleteSession('current');
removeValue('user')
}
}

The result:

keke this works on Appsmith cloud too

Amazing stuff Steven!

Thank you so much! 😀

Also quick question, I'm reading the docs right now but it seems that updating the user email or name is on seperate APIs? Why is that? why not just put it in one API?

Update email is a bit more complicated and requires extra authentication

Hey sorry to bring this ticket up again, but I wanted to ask if I'm using the SDK will it try to connect to an internet? Because when I try it offline it seems like it doesnt work. I have the appwrite self hosted locally and the sdk endpoint pointing to that endpoint

Nope, it only connects to the endpoint you specify.
Btw, it's best to make a new post in <#1072905050399191082> rather than reusing an old post for a different topic

sorry about that thankyou for the quick reply
Recommended threads
- React native app login via Safari
Hi! I deployed for debug my React Native app in web, chrome everythink works well but in safari on mac and ios I cant login. I found this one error in safari co...
- Invalid credentials after migration
Hi everyone! After migrating our self-hosted Appwrite 1.3.1 to another server (staging, so a different domain), we are now getting 'Invalid credentials' when ...
- implement caching
It it possible to cache response for few minutes? I dont want to create function or implement a whole reverse server just to cache it in somewhere ?
