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

Package does not support multiple domains in Android #265

Closed
6 tasks done
guy-plentific opened this issue May 30, 2023 · 11 comments
Closed
6 tasks done

Package does not support multiple domains in Android #265

guy-plentific opened this issue May 30, 2023 · 11 comments
Assignees

Comments

@guy-plentific
Copy link

guy-plentific commented May 30, 2023

Checklist

  • The issue can be reproduced in the auth0_flutter sample app (or N/A).
  • I have looked into the README and have not found a suitable solution or answer.
  • I have looked into the API documentation and have not found a suitable solution or answer.
  • I have searched the issues and have not found a suitable solution or answer.
  • I have searched the Auth0 Community forums and have not found a suitable solution or answer.
  • I agree to the terms within the Auth0 Code of Conduct.

Description

When using this package in Android we have to specify the Auth0 domain in the build.gradle file like:
manifestPlaceholders['auth0Domain'] = "xyz.us.auth0.com"

We have multiple domains that we use for dynamically changed namespaces such as EU/US. The particular domain is not known at compile time, and the user can change it on the login page within the app (before they are presented with the Auth0 web-view to login). Because of this we are having difficulty getting login to work using this package.

I did notice there were some similar issues raised for other Auth0 projects:

How can we overcome this issue in order to be able to migrate to this official package, any help is greatly appreciated.

Reproduction

Please see description.

auth0_flutter version

1.1.0

Flutter version

3.7.6

Platform

Android

Platform version(s)

13

@Widcket
Copy link
Contributor

Widcket commented May 30, 2023

Hi @guy-plentific, thanks for raising this. @poovamraj could you please take a look?

@poovamraj
Copy link
Contributor

@guy-plentific The best way to go ahead would be to follow the instruction from our Auth0.Android SDK
Basically you can override your manifest file to receive callback from multiple domains to open back the SDK. You can check the solution here - https://github.com/auth0/auth0.android/blob/main/FAQ.md#2-why-do-i-need-to-declare-manifest-placeholders-for-the-auth0-domain-and-scheme

@guy-plentific
Copy link
Author

@poovamraj Many thanks for such a fast response! I have been able to override the manifest file and add multiple intent filters, one for each of our domains - it is now working as expected :)

Please consider updating the documentation/FAQs with instructions on how to support multiple domains in Android, possibly with an example of this being done.

@guy-plentific
Copy link
Author

For anyone facing the same problem, here is an example of what we added to our Android manifest:

<!-- The following activity enables redirection from Auth0 web view and is required for auth0_flutter package -->
        <activity
            android:name="com.auth0.android.provider.RedirectActivity"
            android:exported="true"
            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" />

                <!-- Staging EU -->
                <data
                    android:host="xyz-staging.eu.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
                <!-- Staging US -->
                <data
                    android:host="xyz-us-staging.us.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
                <!-- Production EU -->
                <data
                    android:host="xyz.eu.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
                <!-- Production US -->
                <data
                    android:host="xyz-us.us.auth0.com"
                    android:pathPrefix="/android/${applicationId}/callback"
                    android:scheme="com.plentific.xyz" />
            </intent-filter>
        </activity>

@ChrisOgden
Copy link

@guy-plentific Was there an equivalent change you needed to make for iOS as well?

@guy-plentific
Copy link
Author

@guy-plentific Was there an equivalent change you needed to make for iOS as well?

No there wasn't; iOS was straightforward to setup by following the package documentation.

@youssefAbid
Copy link

I am facing probebly the same issue but the diffrence is thate each cutomer will have it's own domain and scheema. is it possible some how to override that data base on an external file ?

the application will be downloaded from the appStore/playstore
each customer have it's own domain and scheema

is there any solution @guy-plentific @poovamraj @ChrisOgden @Widcket ?

@guy-plentific
Copy link
Author

I am facing probebly the same issue but the diffrence is thate each cutomer will have it's own domain and scheema. is it possible some how to override that data base on an external file ?

the application will be downloaded from the appStore/playstore each customer have it's own domain and scheema

is there any solution @guy-plentific @poovamraj @ChrisOgden @Widcket ?

I don't think this will be possible at runtime. I believe you will have to release an updated app version with new info in the manifest each time there is a new customer.

@ChrisOgden
Copy link

I am facing probebly the same issue but the diffrence is thate each cutomer will have it's own domain and scheema. is it possible some how to override that data base on an external file ?
the application will be downloaded from the appStore/playstore each customer have it's own domain and scheema
is there any solution @guy-plentific @poovamraj @ChrisOgden @Widcket ?

I don't think this will be possible at runtime. I believe you will have to release an updated app version with new info in the manifest each time there is a new customer.

@youssefAbid I would agree with @guy-plentific here based on my understanding. A small version bump in the app store shouldn't be too much of an issue for users though.

@youssefAbid
Copy link

Thank you very much @guy-plentific @ChrisOgden that was helpful!

@simon-zhangmuye
Copy link

Hello everyone, my company has many clients who are using Auth0, and we want to link all users to one application. However, currently, we can only do this by configuring all the user information in the AndroidManifest.xml. If we need to add a new client, we must update the entire application. This brings great inconvenience to our users. So, I would like to ask if there is a way to dynamically add domains. For example, by obtaining all the domain information through an API when the application loads?

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

6 participants