Google.logInAsync never return in detached android app

Using Expo v20.

Google.logInAsync using the web behavior never returns in detached android app. The account selection web page do show up but nothing happens after picking an account.

Works fine on detached iOS app.

I’ve follow the steps to set it up for standalone app and it works before detach. Is there any other configurations required for the google login to work in detached android app?

Try adding this to your AndroidManifest.xml, if it does fix the issue I’ll make sure to update the doc to mention that.

    <activity
        android:name="net.openid.appauth.RedirectUriReceiverActivity"
        tools:node="replace">
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="<YOUR_APP_SCHEME>" android:path="oauthredirect"/>
      </intent-filter>
    </activity>

    <activity
      android:name="host.exp.exponent.oauth.OAuthResultActivity">
    </activity>
1 Like

Where can I find YOUR_APP_SCHEME ?

I assume the scheme is for the login web to redirect back to my app?

But the current behavior is that the account selection web page do show up, after picking an account the web page do close itself (returns to my app), but nothing happens.

@janic I found the YOUR_APP_SCHEME in app.json under exp.detach.scheme and add the stuff in AndroidManifest.xml and then run react-native run-android, got:

FAILURE: Build failed with an exception.

* What went wrong:
Cannot read packageName from /Users/philipchen/repos/md-mobile/android/app/src/main/AndroidManifest.xml

There’s a fatal error saying tools of tools.node is not connected.

@philip_mvpfastlane I was also facing the same issue with Google login in a detached app upon using the code mentioned by Janic. On searching for this issue I came across this Stackoverflow thread that helped solved the tools:node error - android - uses-sdk element cannot have a "tools:node" attribute - Stack Overflow

But even after that the Google login was not working and after hours of searching I came across the instructions in the AppAuth repo (which I believe what Expo uses internally) - https://github.com/openid/AppAuth-Android
The solution is to use the app’s reverse url scheme in AndroidManifest.xml so that the final working code that needs to be added there is

    <activity
        android:name="net.openid.appauth.RedirectUriReceiverActivity"
        tools:node="replace">
      <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
        <data android:scheme="com.example.app"/>
      </intent-filter>
    </activity>

    <activity
      android:name="host.exp.exponent.oauth.OAuthResultActivity">
    </activity>

In the above code replace com.example.app with your own app’s reverse url scheme

@janic Please update the Expo docs as soon as possible with this info so that it saves everyone the hassle of searching for hours to solve these issues.

1 Like

you are awesome thanks.

Hey @cosmocoder, @philip_mvpfastlane - did you all ever figure out a solution for this that involved other items in the AndroidManifest.xml?

I am using https://github.com/FormidableLabs/react-native-app-auth as well, and setting it up the exact same way, but the authorize() call never returns on Android after I finalize the login. I can’t help but thinking that the Expo activity, perhaps even the one that provides the menu button or the “shake to view menu” in development mode, is capturing the intent?

Following up here, an issue has been created: https://github.com/expo/expo/issues/1612