Back

React Native Google OAuth Redirect

  • 1
  • Android
  • React Native
  • Apple
  • Auth
Reqima
13 Feb, 2025, 07:55

For 3 days I no longer understand why redirects with Google Auth on React Native do not work at all. I saw people asking the problem but the solutions do not work for me. Please help me.

// ... code

const oauthProvider = { google: OAuthProvider.Google, apple: OAuthProvider.Apple, }[provider.toLowerCase()];

TypeScript
if (!oauthProvider) {
  throw new Error(`Unsupported provider: ${provider}`);
}
const redirectSuccessUri = Linking.createURL("/");
const redirectFailureUri = Linking.createURL("/error");
const response = account.createOAuth2Token(
  oauthProvider,
  redirectSuccessUri,
  redirectFailureUri
);

if (!response) {
  throw new Error("Response is undefined");
}

// ... code

TL;DR
Developers are having trouble getting Google OAuth redirects to work in React Native, even after trying various solutions found online. One potential solution to fix the issue could be to ensure that the redirectSuccessUri and redirectFailureUri are correctly specified and matching the expected values on the Google API side. Double-checking the implementation details and configuration of OAuthProvider.Google could also help in resolving the problem.
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