const result = account.createOAuth2Session('google','http://localhost:5173/me','http://localhost:5173/failed');
console.log('From google sign in', result);
e.preventDefault();
}
clicking on the button redirects to google and back to http://localhost:5173/me but no cookies are being set and account.get() returns 401
Summary
The problem in this support thread is that there are multiple redirects happening during the Google OAuth flow and the SDK does not have access to the responses after the first one. The issue is resolved by using custom domains. The cookies set during the process are considered third-party cookies by the app, so they are not sent when making API calls to Appwrite. The solution is to ensure that third-party cookies are enabled. The thread provides a step-by-step explanation of the OAuth flow and clarifies that there is no fallback header on the redirect. The problem with not being able to set cookies and getting a 401 error is resolved by using custom domains
Nevus
Rank 4: Virtual Machine
Jun 17, 2023, 15:25
I am using cloud and I am stuck with no logs
Drake
Jun 17, 2023, 15:25
It's probably due to 3rd party cookies. There should be previous #channel threads on this
Nevus
Rank 4: Virtual Machine
Jun 17, 2023, 15:25
isn't there a fallback?
Drake
Jun 17, 2023, 15:27
The fallback isn't used in the oauth flow because it's not possible to set the header on redirect
Nevus
Rank 4: Virtual Machine
Jun 17, 2023, 15:30
ahh
I thought the flow was browser->cloud.appwrite.io->google->cloud.appwrite.io->browser
Drake
Jun 17, 2023, 15:33
Sort of...this all happens in the browser so instead of browser, that should be your app
Drake
Jun 17, 2023, 15:34
And so during that redirect from cloud to your app, it's not possible to set the fallback header
Nevus
Rank 4: Virtual Machine
Jun 18, 2023, 01:23
How is this different from using createEmailSession?
Response 4: Redirect to my app using success parameter.
And third party cookies are needed because fallback headers can't be set on response 3?
Nevus
Rank 4: Virtual Machine
Jun 18, 2023, 01:59
soo many redirects 😭
Nevus
Rank 4: Virtual Machine
Jun 18, 2023, 01:59
or is it the cookies from google that are needed for it to work?
Drake
Jun 18, 2023, 02:09
Cookies are set at step 9, but they're considered 3rd party cookies by your app, so they aren't sent when your app makes API calls to Appwrite
Nevus
Rank 4: Virtual Machine
Jun 18, 2023, 02:11
aye so custom domains are the solution?
Nevus
Rank 4: Virtual Machine
Jun 18, 2023, 02:16
so the problem is that the there's a bunch of redirects happening and the sdk doesn't have access to any responses after Response 1. Cookies work only because browser automatically sends them.