Auth0 Home Blog Docs

Multiple callbacks on Android

android
callback-urls
callbacks

#1

Is it possible to have two activities each one with a different callback? I tried this on the Android Manifest:

<activity
    android:name=".LoginActivity"
    android:launchMode="singleTask">
    <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:host="@string/auth0_domain"
            android:pathPrefix="/android/it.siwego.clientapp/login/callback"
            android:scheme="https"/>
    </intent-filter>
</activity>

<activity
    android:name=".RegisterActivity"
    android:launchMode="singleTask">
    <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:host="@string/auth0_domain"
            android:pathPrefix="/android/it.siwego.clientapp/register/callback"
            android:scheme="https"/>
    </intent-filter>
</activity>

I wanna be able to use Facebook login/register from both of them, but when I try to do this I get a webpage that says The url https://siwego.eu.auth0.com/android/it.siwego.clientapp/callback is not on the list of allowed callbacks URLs. And then the two URLs I added to the Manifest are listed.


#2

The reason for the error is that you configured two allowed callback URL’s (the login and register one), but the application is still trying to use the default one which is not in the allowed list and so it fails.

By default the Android callback URL will be:

{scheme}://{auth0_account_domain}/android/{application_package_name}/callback

Given that both the {auth0_account_domain} and {application_package_name} are static values within the same application the only way to introduce multiple callback URL’s would be to use different schemes.

In conclusion, although you can’t configure the path portion of the callback URL you may consider having different schemes so that you can register different intents. You would then use the withScheme method of the Android SDK to state that you want to use a different scheme depending on the situation.


#3