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
- Send Email Verification With REST
I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the v...
- Use different email hosts for different ...
Hello, I have 2 projects and i want to be able to set up email templates in the projects. Both projects will have different email host configurations. I see ...
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...