How do I grant the newly created user permission to read their own session on verified?
- 0
- Web
- Accounts
- Cloud
- Self Hosted
- Users
callback hell 😵💫 I highly recommend using try/await/catch instead of promises and nested callbacks.
what exactly are your full console logs with this code?
I prefer not to use try catch because I generally have no idea where the error was thrown. The logs in then() and catch() both run. And the error was mentioned above
I prefer not to use try catch because I generally have no idea where the error was thrown. Why not?
And the error was mentioned above I was asking for the console logs that show the full output of:
console.log("New session created: ")
console.log(response); // Success
console.log({userId} )
console.log("Error when update URL SESSION")
console.log("Success getting session")
console.log(response); // Success
So I actually figure out why, so Appwrite failed to set cookie so that's why I'm seeing cookieFallback in my localStorage. My understanding now is to set mydomain.com -> appwrite.mydomain.com so that Appwrite can set cookie in my browser. However, I'm hosting my app on vercel so that would be *.vercel.app, is there any alternative way?
Shouldn't there be a prvider access token be returned so that I can set cookie manually? {
"$id": "647a1790f3101a8be71b",
"$createdAt": "2023-06-02T16:23:45.007+00:00",
"userId": "6479f90459eb835c464e",
"expire": "2024-06-01 16:23:44.995",
"provider": "magic-url",
"providerUid": "",
"providerAccessToken": "",
"providerAccessTokenExpiry": "",
"providerRefreshToken": "",
"ip": <MY IP ADDRESS>,
"osCode": "MAC",
"osName": "Mac",
"osVersion": "10.15",
"clientType": "browser",
"clientCode": "CH",
"clientName": "Chrome",
"clientVersion": "113.0",
"clientEngine": "Blink",
"clientEngineVersion": "113.0.0.0",
"deviceName": "desktop",
"deviceBrand": "Apple",
"deviceModel": "",
"countryCode": "ca",
"countryName": "Canada",
"current": true
}
As you can see it's an empty string here
this is the response from const response = await account.updateMagicURLSession(userId, secret);
Appwrite sets the cookie regardless...the problem is your browser can block 3rd party cookies from being sent in future requests. The ensure the cookie is a 1st party cookie, they must share the same base domain. In production, you would have your own domain that you can set up. If you don't have a domain, you can modify the hosts entry on your machine for local development.
That said, the fallback header should work still...
this is expected. that provider access token is for OAuth2 sessions and the token is the token from the OAuth2 provider
uhmmm the fallback header set session cookies in the localStorage. So what would be your recommendation to handle in this situation ? Perhap, retrieve it from localstorage manually and then set cookies? so that after you can call account.get() ?
it should all be done automatically...what's your platform?
I'm using Nextjs and setting hostname as localhost
nextjs...so it won't work if the account.updateMagicURLSession(userId, secret) is done server side. because the cookie wouldn't exist client side
I don't see any cookie is set...
i'm doing account.updateMagicURLSession(userId, secret) in the useEffect()
where are you looking?
I checked session storage and cookies as well
nothing was there
but you're probably on your client app. the cookie won't be on your client app. it would be on your appwrite instance. so browse to your appwrite instane and do the same thing
I'm doing it through the cloud sdk...
you mean Appwrite Cloud? Then check the cookies when on Appwrite Cloud...
I might be dumb, how exactly can I check the cookies when on Appwrite Cloud ?
Browse to the appwrite cloud console and do the same thing here
I'm just gonna set it up manually from the fallback cookie since my browser is blocking it 😆 . Thanks for your support 🙏
Recommended threads
- Many2Many loading, not receiving list
Hi everyone! Im having a bit of trouble while editing single rows in the DB. When selecting a value of my many2many it keeps loading, see screenshot. On some ...
- Appwrite Python SDK Keeps returning the ...
So I have a couple services, one is a scheduling engine responsible for fetching data from a database and launching a containerized micro service to process tha...
- SSR Auth with Tanstack Start requires ha...
I followed the Next.js guide for SSR Auth on https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-1 I tried to replicate it for Tanstack Start. However, on...