开发者

Retrieve a verifier from a callback URL using Java

I am new to java developm开发者_运维问答ent environment. Any help will be really appreciated.

I have an orkut app developed to work on my mobile application. It uses OAuth 2.0. I succeeded in

  1. getting the authorizationURL

  2. launching a browser with this URL

  3. logging in using userid and password

  4. Redirected to callbackURL.

    I want to extract the "oauth_verifier" parameter from the URL into a variable in my javacode for further authentication. Or please help me to get the callbackURL with parameters from the browser.

Please help me !!!

Thanks in advance.


You can use setWebViewClient method of webview and then implement a new webViewClient, then you can access full url by using onPageFinished method. see code below.

webView.setWebViewClient(new WebViewClient()
{

    @Override
    public void onPageFinished(WebView view, String url)
    {
        if (url.contains("#access_token=")) //I am looking for #access_token= hash, you can look for any parameter here
        {
            String accessToken = url.substring(url.indexOf("#access_token=") + 14, url.length()); //14 is my "#access_token=" length, yours will be different
            writeAccessTokenToFile(accessToken); //this method is your method
            loadApplication(); //then load you application logic, this is your method too
        }
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜