3

I have to implement Custom Tabs into a app that uses a webview login with OAuth functionality. Is there a way to have to same behavior as onPageStart() and onPageFinished() into Chrome Custom Tabs?

William Denniss
  • 16,089
  • 7
  • 81
  • 124
James ONeal
  • 131
  • 2
  • 4
  • Sorry, I am new to coding. Can you give me an example of overriding the onNavigatonEvent and using the NAVIGATION_STARTED AND NAVIGATION_FINISHED. I don't see where they did it in the sample.Thank you so much. – James ONeal Apr 04 '16 at 13:57
  • When using Chrome Custom Tabs you get the OAuth redirect back as an intent, rather than by using `onPageFinished()`. It's a slightly different way to achieve the same result (app gets the authorization response). The Authorization Server you're using does need to be allow custom URIs in redirects for this to work (Google's Authorization Server supports this, as can be seen in the AppAuth demo). – William Denniss Apr 21 '16 at 23:18

2 Answers2

4

If you're using Chrome Custom Tabs to do OAuth (great idea by the way – far more secure and usable than WebView) then you should consider the open source AppAuth library.

Even if you don't depend on the library directly, it has some good examples for implementing OAuth flows with Chrome Custom Tabs.

William Denniss
  • 16,089
  • 7
  • 81
  • 124
1

You can implement a CustomTabsCallback and override onNavigationEvent. Use NAVIGATION_STARTED and NAVIGATION_FINISHED.

You need to pass the CustomTabsCallback as a parameter when creating a new session. Take a look at this sample.

The limitation is that you won't have access to the URL that is being loaded, specially if the user navigates away from the Url used to open the Custom Tab.

andreban
  • 4,621
  • 1
  • 20
  • 49