Skip to content
Back

Oauth2 works on localhost but not on mobile

  • 1
  • React Native
  • Cloud
Rugile
1 Jan, 2025, 06:28

i was able to use google login on localhost, but when i swich to virtual andoid wtih eas build i get {"type":dismiss} from WebBrowser, wtf is happening. i created web profile and set Hostname to "*", code: `export const signInWithGoogle = async () => { try { const redirecting = Linking.createURL("google", { scheme: "quizapp", isTripleSlashed: false });

TypeScript
const responseData = await account.createOAuth2Token(
  OAuthProvider.Google,
  redirecting
);

const res = await WebBrowser.openAuthSessionAsync(
  responseData.toString(),
  redirecting,
);
console.log("googleLogin", res)
if (res.type === "success") {
  const data = parseUrl(res.url)
  const secret = data?.query?.secret
  const userId = data?.query?.userId
  const ses = await account.createSession(userId, secret);
  return { success: true, session: ses };
}

} catch (error) { console.log(error); return { success: false }; } };`

TL;DR
Oauth2 is working on localhost but not on mobile, getting {"type":dismiss} error. The issue may be related to the redirect URL setting. To solve this, check the redirect URL settings and make sure it's configured correctly for mobile.
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