expo-auth-session/providers/google Android Standalone Issue

Hi Everyone
First off I have been scoring the web for answer and tried everything they suggested but nothing has resolved this aggravating issue

I’m using expo-auth-session/providers/google and on IOS it works perfectly but on Android I keep running up against this race issue that causes the google sign in to not redirect back to the app and default to a “response: dismiss”.

Can anyone point me to a reliable fix for this? Otherwise can anyone suggest a different library that will work on React-native & Expo that will get my google login to work?

This has been a long hard battle and I’m really stuck so any help would be awesome

On Expo SDK 48
Thanks

Hey @freem11,

I responded to your queries on the thread: Potential liability with instructions for Google Authentication - #11 by amanhimself

If you can share a minimal reproducible example, I’m happy to look into it.

Also, as @wodin suggested, you can try using the following library:

@amanhimself
Not sure if this is enough but here is all my code for this:

package.json:
“expo-application”: “~5.1.1”,
“expo-auth-session”: “~4.0.3”,
“expo-crypto”: “~12.2.1”,
“expo-web-browser”: “~12.1.1”

app.json:
“scheme”: [“com.divego”, “fbXXXXXXX”]

sign in page:
import * as WebBrowser from “expo-web-browser”;
import * as Google from “expo-auth-session/providers/google”;

WebBrowser.maybeCompleteAuthSession();

const googleExpoClientId = config.EXPO_CLIENT_ID;
const googleAndroidClientId = config.ANDROID_CLIENT_ID;
const googleIOSClientId = config.IOS_CLIENT_ID;
const facebookAppId = config.FACEBOOK_APP_ID;

export default function SignInRoute() {

const [req, res, promptAsync] = Google.useAuthRequest({
androidClientId: googleAndroidClientId,
iosClientId: googleIOSClientId,
expoClientId: googleExpoClientId,
});

useEffect(() => {
handleGoogleSignIn();
}, [res]);

async function handleGoogleSignIn() {
alert(“response?” + res.type)
if (res?.type === “success”) {
await getGoogleUserData(res.authentication.accessToken);
}
}

<TouchableWithoutFeedback
onPress={() => {promptAsync();
}}
disabled={!req}
>

      <View style={[styles.SignUpWithButtons]}>
        <Image source={googleLogo} style={[styles.gLogo]} />
        <Text
          style={{
            color: "#FFFFFF",
            fontFamily: "PermanentMarker_400Regular",
            fontSize: 12,
            opacity: 0.7,
          }}
        >
          Sign In With Google
        </Text>
      </View>
    </TouchableWithoutFeedback>

}

the alert always comes back with “response?dismiss”

again on IOS it works without any issue, but on Android standalone I’m always getting this result

I’d suggest removing expoClientId as its not required anymore since Proxy is deprecated with SDK 48. Also, are you creating a development build?

I have removed the expoClientId as you suggested

The latest build is still returning with response?dismiss

Regarding development builds. - npx expo run:ios. runs just fine
but
npx expo run:android is failing with:
1: Task failed with an exception.

  • Where:
    Script ‘/Users/matthewfreeman/dgmobile/frontend/DiveGoMobile/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle’ line: 326

  • What went wrong:
    A problem occurred evaluating project ‘:expo’.

A problem occurred configuring project ‘:expo-modules-core’.
Failed to notify project evaluation listener.
SDK location not found. Define a valid SDK location with an ANDROID_HOME environment variable or by setting the sdk.dir path in your project’s local properties file at ‘/Users/matthewfreeman/dgmobile/frontend/DiveGoMobile/android/local.properties’.
Could not get unknown property ‘release’ for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

So i have been doing build to the google play store to test, is there something you can recommend to sort out the Android build issue? I have tried a few suggestions online but maybe i just need to uninstall and reinstall expo and all the associated libraries? (if there is an easier way please share)

Thank you for you help so far by the way I do appreciate it, and this Android issue has been awful to deal with on my own.

From above, it seems that the ANDROID_HOME env variable is not set to the Android SDK directory that is created when you install Android Studio. React Native docs explain on how to do so: Setting up the development environment · React Native

You’ll have to check and make sure that is set correctly and then run npx expo run:android command again. This is not an Expo related issue.

whew ok had to fumble around a bit but got the Android Home issue resolved and npx expo run:android now build successfully, however, once built I tried the google sign in and got the same result as i was getting on google play testing selecting an account spins for a bit then goes to the google homepage instead of redirecting, sometimes it also does redirect, but the result is still no sign in and my alert for the response still comes up with “response?dismiss”

Is there any other info I can supply you with that could be helpful to resolve this auto dismiss that google keeps giving?

@amanhimself If there is nothing else I can send you to help out, I was thinking that you said you tested on your end and it was working fine, would you be able to send me how yours is coded so that I can look it over and hunt around for a discrepancy between yours and mine?