views:

83

answers:

1

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?

A: 

You need to implement a WebViewClient to intercept the custom URI before it is loaded. The Hello, WebView tutorial (http://developer.android.com/guide/tutorials/views/hello-webview.html) 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.

Ian G. Clifton