Henric Henric - 3 years ago 141
Android Question

CustomTabs shows ERR_UNKNOWN_URL_SCHEME after 302 Redirect

I'm trying to implement OAuth2 login flow using Custom Tabs, but after login has been successful a 302 Redirect is retrieved with url as the following: "my.app:/oauth2/code?xxx".

Now I have declared redirect URI in AndroidManifest to listen to this, but ERR_UNKNOWN_URL_SCHEME is seen :/

<intent-filter>
<data
android:host="oauth2"
android:scheme="my.app"
android:pathPrefix="/code"
/>

<action android:name="android.intent.action.VIEW" />

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


I've tried different url-schemes to listen to, but none seems to be triggered to open my app.

Answer Source

The issue had to do with the identification happening in another app. So when I resumed the CustomTabs, somehow the context was lost. :/

Basically this is what we wanted to do:

MyApp -> CustomTabs -> Identify with other app (from redirect) -> Resume CustomTabs (loading screen) -> redirect to MyApp.

But since the second redirect couldn't be made, we tried another angle for the problem.

Our solution that worked was to break up the flow for the authentication:

MyApp -> CustomTabs -> redirect to MyApp -> Identify with another app -> redirect to MyApp -> CustomTabs (loading screen) -> redirect to MyApp with result.

Hopefully this helps someone with similar issue at least.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download