'expo-auth-session - Two app options on return to app

SDK Version: 43.0.0

Platforms(Android/iOS/web/all): Android

Hello, I'm using expo-auth-session in the managed workflow to collect Instagram user data through its official API, it's working fine on the development environment (through the "expo run:android" command), but once a build APK is created when the user makes the authorization process and the redirect starts there is a popup asking “Open with” and two options for my app, the first one works perfectly the second one goes back to the app but does nothing, I didn't test on IOS.

Here is the image that represent it: Click here to see

When I was developing I tried to do the google sign-in process but was stuck in the same error, partially resolved by implementing google native sign-in. I verified my schemes in app.json but didn`t identify wrong on it, as follows:

app.json:

{
    "expo": {
        "name": "Secreet",
        "slug": "secreet",
        "version": "1.0.0",
        "orientation": "portrait",
        "icon": "./assets/icon.png",
        "scheme": "com.davidtmiranda.secreet",
        "splash": {
            "image": "./assets/splash.png",
            "resizeMode": "contain",
            "backgroundColor": "#ffffff"
        },
        "updates": {
            "fallbackToCacheTimeout": 0
        },
        "assetBundlePatterns": ["**/*"],
        "ios": {
            "supportsTablet": true,
            "usesAppleSignIn": true,
            "bundleIdentifier": "com.davidtmiranda.secreet",
            "googleServicesFile": "./GoogleService-Info.plist",
            "config": {
                "googleSignIn": {
                    "reservedClientId": "com.googleusercontent.apps.--------------------"
                }
            }
        },
        "android": {
            "versionCode": 1,
            "adaptiveIcon": {
                "foregroundImage": "./assets/adaptive-icon.png",
                "backgroundColor": "#FFFFFF"
            },
            "package": "com.davidtmiranda.secreet",
            "googleServicesFile": "./google-services.json"
        },
        "web": {
            "favicon": "./assets/favicon.png"
        }
    }
}

also, my authSession code looks like this:

    webBrowser.maybeCompleteAuthSession();
    const useProxy = Platform.select({ web: false, default: true });

    const client_id = ---;
    const redirect_uri = "https://auth.expo.io/@davidtmiranda/secreet";
    const scope = "user_profile";

    const site =
        "https://api.instagram.com/oauth/authorize?client_id=" +
        client_id +
        "&redirect_uri=" +
        redirect_uri +
        "&scope=" +
        scope +
        "&response_type=code&state=1";

    const discovery = { authorizationEndpoint: site };

    const [request, response, promptAsync] = useAuthRequest(
        {
            redirectUri: makeRedirectUri({
                useProxy,
                native: redirect_uri,
            }),
            scopes: [scope],
            clientId: String(client_id),
        },
        discovery
    );

    useEffect(() => {
        if (response?.type === "success") {
       ...
        } 
    }, [response]);

    function GetInstagramID() {
        return promptAsync({
            useProxy,
        });
    }

Any suggestions about how to solve this problem? I believe it is schema-related but could not identify what is wrong.



Solution 1:[1]

Maybe you can try to remove scheme in the app.json

"scheme": "com.davidtmiranda.secreet",

and it will change appAuthRedirectScheme in the android/app/build.gradle

manifestPlaceholders = [appAuthRedirectScheme: 'com.davidtmiranda.secreet']

It solves my issue.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Norman Chen