Back

upgraded to 1.6, Google oauth stopped working

  • 0
  • Self Hosted
  • Auth
  • Web
elnur
22 Sep, 2024, 16:24

Don’t seem to see any changes between 1.5.10 and 1.6.0.

I’m getting ”invalid redirect” url error. Doesn’t seem right.

TL;DR
Developers upgraded to version 1.6, Google OAuth stopped working due to an issue with 3rd party cookies. They need to test on an actual domain. A patch is being worked on. The login flow fails with a redirection error and 401 Unauthorized code. Update to 16.0.1 and check. A specific GitHub issue was mentioned for reference. The provided code includes the SocialSignInButton component with OAuth2 session creation and user data retrieval.
elnur
22 Sep, 2024, 20:57

code

TypeScript
const SocialSignInButton = ({ provider, disabled }) => {
  const getText = useLocalizedText();
  const { account } = useAppwrite();
  const { saveUserToDB } = useUser();

  const location = window.location.origin;
  const successUrl = `${location}/`; // eg localhost:5173/login
  const failureUrl = `${location}/login`; // eg localhost:5173/login

  const signInWithGoogle = async () => {
    try {
      await account.createOAuth2Session(
        OAuthProvider.Google,
        successUrl,
        failureUrl
      );
      // After successful OAuth login, fetch the account to get user details
      const user = await account.get();
      // Save or update user in the database
      await saveUserToDB(user);
    } catch (error) {
      console.error("Error logging in with Google:", error);
    }
  };
elnur
22 Sep, 2024, 20:58
Steven
1 Oct, 2024, 18:39

Is this your GItHub issue? https://github.com/appwrite/appwrite/issues/8712

Want to share with me your endpoint and project ID via DM so I can test?

elnur
1 Oct, 2024, 18:52

Yeah sure I’ll dm

Steven
1 Oct, 2024, 19:55

what's your tech stack?

Steven
2 Oct, 2024, 14:14

@eren can you update to 16.0.1 and try again?

elnur
2 Oct, 2024, 14:46

The redirection error is solved. However, the login flow didn't succeed. I arrive at the Google screen, then choose my account. I get redirected back to the app and then the network call account gets the 401 Unauthorized code.

The image claims I don't have the scope. I also noticed that the redirect URL always has a "#" at the end regardless of the URL I want. Eg "/" becomes "/#" or "/hey" becomes "/hey<#null>

Steven
2 Oct, 2024, 20:40

is this local or with a real domain?

elnur
2 Oct, 2024, 20:44

Localhost dev server that still talks to the real domain. But the app is running in localhost

Steven
2 Oct, 2024, 21:32

just found a problem with the web sdk regarding 3rd party cookies. we're going to try to push out another patch

Steven
2 Oct, 2024, 21:32

it should work on an actual domain though because it won't be a 3rd party cookie

Steven
2 Oct, 2024, 22:00

@eren okay, just released 16.0.2. Can you try with that?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more