Back

Type: general_bad_request

  • 1
  • React Native
chrissiku
12 Feb, 2025, 21:40

When authenticating with Google OAuth in react native, I'm getting the error 400 saying : There was an error processing your request. Please check the input and try again.

Type general_bad_request

is the anyway to fix this ??

TL;DR
Developers facing issues with using OAuth2 for Google in their React Native app. The error message "general_bad_request" with code 400 is persisting despite trying different methods. Are there any solutions available to resolve this issue? Solution: The problem might be due to the lack of full support for OAuth2 in React Native. Try alternative approaches or libraries that provide better compatibility for Google OAuth in React Native.
chrissiku
12 Feb, 2025, 21:45

as on the following image.

and bellow is the code

TypeScript
export async function login() {
  try {
    // const redirectUri = Linking.createURL("*/");
    // const failureUri = Linking.createURL("myapp://sign-in");

    const redirectUri = Linking.createURL("myapp://redirect");
    const failureUri = Linking.createURL("myapp://sign-in");

    const response = await account.createOAuth2Token(
      "google" as OAuthProvider.Google,
      // OAuthProvider.Google,
      redirectUri,
      failureUri
    );

    if (!response) throw new Error("Create OAuth2 token failed 1");

    const browserResult = await openAuthSessionAsync(
      response.toString(),
      redirectUri
    );

    console.log({ browserResult });

    if (browserResult.type !== "success")
      throw new Error("Create OAuth2 token failed 2");

    const url = new URL(browserResult.url);
    const secret = url.searchParams.get("secret")?.toString();
    const userId = url.searchParams.get("userId")?.toString();

    if (!secret || !userId) throw new Error("Create OAuth2 token failed");

    const session = await account.createSession(userId, secret);
    if (!session) throw new Error("Failed to create session");

    return true;
  } catch (error) {
    console.error(error);
    return false;
  }
}

I've tried what worked before and new method but unseccessfull.

Please if there is someone with the solution, could you share >

Steven
12 Feb, 2025, 21:59

Worked before? Oauth2 for react native isn't fully supported yet

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