auth0-samples / auth0-android-sample

Auth0 Integration Samples for Android Applications
https://auth0.com/docs/quickstart/native/android
MIT License
77 stars 141 forks source link

Android: ability have multiple (or toggle) auth0Domain on manifestPlaceholders at runtime? #109

Closed VladSVAssets closed 3 years ago

VladSVAssets commented 3 years ago

Hello,

I am currently following this documentation: Android: Login

My question concerns the build.gradle file for the app.

// —> Add the next line manifestPlaceholders = [auth0Domain: “@string/com_auth0_domain”, auth0Scheme: “demo”] // <—

I also see that these values, per documentation:

The placeholders are used internally to define an intent-filter that captures the authentication callback URL.

I have a situation where I must toggle the domain between (or have it from the start to accept) the development and production environments. Auth0 is unable to complete authentication on my Android app because those values are dynamic, and from the documentation the domain is a static value with only one url domain accepted.

The only “solution” I’ve found is to set the host value to use a wildcard (*.mydomain.com), but this does not work too well for my domains and it does not seem to be a safe implementation.

VladSVAssets commented 3 years ago

I want to mention that I need to toggle on the same build (not separate depending on the flavor for example), because on my application the user can swap environments at runtime.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you have not received a response for our team (apologies for the delay) and this is still a blocker, please reply with additional information or just a ping. Thank you for your contribution! 🙇‍♂️

Sagarito commented 3 years ago

Was this issue ever resolved? I am facing the same problem.

alexandrudumbravan-nutmeg commented 2 years ago

Hello

For what it's worth there is a workaround to the issue.

Add the Auth0 Redirect to the manifest and declare different placeholders like the following example:

<activity android:name="com.auth0.android.provider.RedirectActivity" android:exported="true" tools:node="replace"> <intent-filter android:autoVerify="true" tools:targetApi="m" >

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="${domain1}"
                android:pathPrefix="/android/${applicationId}/callback"
                android:scheme="${scheme1}" />

            <data
                android:host="${domain2}"
                android:pathPrefix="/android/${applicationId}/callback"
                android:scheme="${scheme2}" />
        </intent-filter>

    </activity>

This allows you to link multiple callbacks from different environments