5

I am doing authentication with a third-party site that's supposed to redirect back to my app with auth token (OAUTH).

I have the callback working properly if I open the 3rd party site in a separate browser process via

this.startActivity(new Intent(Intent.ACTION_VIEW, uri)); 

but, if I embed a WebView component in my layout, and open the url in that, the callback does not work. Webview says "You do not have permission to open myapp://callback?token=...." and quickly refreshes to "Web page not available...temporarily down...blah blah"

Any ideas?

1 Answer 1

17

You need to implement a WebViewClient to intercept the custom URI before it is loaded. The Hello, WebView tutorial shows a simple example. Where they have:

private class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } 

You can change "view.loadUrl(url)" to check if the URL is your custom URL and handle it however you want.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.