Skip to content
Back

Invalid 'success' param error (React Native Android application)

  • 1
  • React Native
Jack TFB
1 Jul, 2025, 21:55

I am trying to set up a "Sign in with Google" button using OAuth2. While I was successful in getting the button to work for web, when I try with mobile I get the error "Invalid 'success' param: URL host must be of: ..." I was able to get it working for web fine without this error, but for my android app, I get this error. Is it due to a wrong configuration?

Here is my code for the login with Google function

TypeScript
async function loginWithGoogle() {

        try {
            const redirectUri = Linking.createURL("/");

            console.log("Platform:", Platform.OS);
            console.log("Redirect URI:", redirectUri);

            if (Platform.OS === 'web') {
                const response = account.createOAuth2Session(
                    OAuthProvider.Google,
                    redirectUri,
                    redirectUri
                );

                if (!response) throw new Error("Failed to create OAuth2 session");

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

                if(browserResult.type !== "success") {
                    throw new Error("OAuth authentication was cancelled or failed");
                }

                const currentSession = await account.getSession('current');
                if (!currentSession) {
                    throw new Error("No session found after OAuth authentication");
                }
                return currentSession;
            } else {
                const response = account.createOAuth2Token(
                    OAuthProvider.Google,
                    redirectUri,
                    redirectUri
                );

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

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

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

                console.log("Browser Result: ", browserResult);

                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");

                await account.createSession(userId, secret);

                const currentSession = await account.getSession('current');
                if (!currentSession) {
                    throw new Error("Failed to create session after OAuth authentication");
                }
                return currentSession;
            }
        } catch (error) {
            console.error("Login error:", error);
            return null;
        }
    }
TL;DR
Developers trying to set up "Sign in with Google" button in React Native Android app are encountering an "Invalid 'success' param" error due to incorrect configuration. The issue seems to arise from OAuth2's partial support in React Native. To fix the problem, developers can refer to the provided GitHub comment for more information on OAuth2 support status.
Steven
1 Jul, 2025, 21:55

OAuth2 with React Native is not fully supported. The GitHub comment explains the current state: https://github.com/appwrite/sdk-for-react-native/issues/34#issuecomment-2654940715

Jack TFB
1 Jul, 2025, 21:56

Gotcha, thank you!

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