Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth.Instance.signIn() doesn't redirect to OAuth login page in Android #300

Open
salesforcecodes opened this issue Nov 12, 2023 · 6 comments

Comments

@salesforcecodes
Copy link

Implemented ionic-appauth package in an ionic react package. I am able to complete the sign in process in the web. But in Android it is not redirecting to the sign in screen.

Using latest ionic and capacitor version

"capacitor/cli": "5.5.1"
"ionic-appauth": "^2.0.0"
"@ionic/react": "^7.0.0"

Is this some issue with configuring AndroidManifest.xml? Here is my file

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
            android:name="com.mydomain.dev.MainActivity"
            android:label="@string/title_activity_main"
            android:theme="@style/AppTheme.NoActionBarLaunch"
            android:launchMode="singleTask"
            android:exported="true">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <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.mydomain.dev://callback" />
            </intent-filter>

        </activity>

        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.fileprovider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths"></meta-data>
        </provider>
    </application>

    <!-- Permissions -->

    <uses-permission android:name="android.permission.INTERNET" />
</manifest>
@salesforcecodes
Copy link
Author

I tried moving the android:scheme attribute as a string resource and removing ://callback at the end. Tried a bunch of other things as well. So far no luck. Appreciate any help!
<data android:scheme="@string/custom_url_scheme" />

@mraible
Copy link
Collaborator

mraible commented Nov 27, 2023

Have you added https://localhost as a Allowed Origins (CORS) on Auth0? This is required for Android.

@salesforcecodes
Copy link
Author

@mraible Thank you for checking. I am using Salesforce as identity provider instead of Auth0. Does that matter. I have added localhost to act as redirect URL already.

@mraible
Copy link
Collaborator

mraible commented Nov 28, 2023

I don't think the identity provider matters. Does Salesforce have an "allowed origins" or CORS setting you can configure?

@salesforcecodes
Copy link
Author

Yeah. That is configured already and a simple oauth flow using the browser redirection works without issues. When I run it from the ionic app it is not launching the initial screen

@YaMoef
Copy link

YaMoef commented Dec 11, 2023

@salesforcecodes hi, I had a similar issue. No CORS issues or errors but browser on android wouldn't open either. Turned out capacitor-secure-storage-plugin wasn't installed which is in the Vue demo. I suggest comparing all installed packages to one of the examples

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants