I am using web sdk with following code:
async function googleSignIn(e) {
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
I am using cloud and I am stuck with no logs
It's probably due to 3rd party cookies. There should be previous <#1072905050399191082> threads on this
isn't there a fallback?
The fallback isn't used in the oauth flow because it's not possible to set the header on redirect
ahh I thought the flow was browser->cloud.appwrite.io->google->cloud.appwrite.io->browser
Sort of...this all happens in the browser so instead of browser, that should be your app
And so during that redirect from cloud to your app, it's not possible to set the fallback header
How is this different from using createEmailSession?
That's a request and response, not a redirect
So, the process is:
- User clicks sign-in button.
- Request 1: GET request to https://cloud.appwrite.io/v1/account/sessions/oauth2/google
- Response 1: 301 redirect to https://accouts.google.com/<whatever>
- User logs in to google.
- Request 2: google
- Response 2: 302 to https://cloud.appwrite.io/v1/account/sessions/oauth2/callback/google with the code and google's cookies
- Request 3: <appwrite cloud>/oauth2/callback/google
- Response 3: Redirect to https://cloud.appwrite.io/v1/account/sessions/oauth2/google/redirect with Set-Cookie headers
- Request 4: <appwrite cloud>/oauth2/google/redirect
- 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?
soo many redirects ðŸ˜
or is it the cookies from google that are needed for it to work?
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
aye so custom domains are the solution?
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.
[SOLVED] Debugging google oauth flow
Recommended threads
- Domain Verification Failed - Fastly Conf...
I am trying to add my subdomain api.getmyself.app to my Custom Domain, but I keep getting the error: Domain 'getmyself.app' is owned by another customer I have...
- Data not loading at the frontend
My App that has been working for weeks, ain't loading anything at the frontend anymore. I thought maybe the API key expired but it's not the case. Users are log...
- Do I need to upgrade my Appwrite plan?
So i am making a file hosting & sharing platform (voltzy.lol) and i am expecting approx 5-8 million visit per month and over 30 million uploads per month do i n...