Admin
Otherwise, Im curious about the configuration of the get current session and how you're setting the headers
Votes
1
Replies
24
Participants
Unknown
Messages
25
Admin
Otherwise, Im curious about the configuration of the get current session and how you're setting the headers
Rank 1: Thread
If I use fetch, how do I get the Fallback-Cookie?
Rank 1: Thread
User (role: guest) missing scope (account) via Appsmith
Admin
Rank 1: Thread
I used console.log(...response.headers) to see all the headers but it only returns me with
Admin
This is from the create email session?
Rank 1: Thread
yes it is
Admin
What's the code and what's the network logs?
Rank 1: Thread
Admin
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?
Admin
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
Rank 1: Thread
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
Admin
That's bizarre it doesn't work...it doesn't make sense...I'll have to play around with this myself in the morning
Rank 1: Thread
Okay thankyou for your quick reply
Admin
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
Admin
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') }}Admin
The result:
Admin
keke this works on Appsmith cloud too
Rank 1: Thread
Amazing stuff Steven!
Rank 1: Thread
Thank you so much! 😀
Rank 1: Thread
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?
Admin
Update email is a bit more complicated and requires extra authentication
Rank 1: Thread
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
Admin
Nope, it only connects to the endpoint you specify.
Btw, it's best to make a new post in #channel rather than reusing an old post for a different topic
Rank 1: Thread
sorry about that thankyou for the quick reply