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
getting the authorizationURL
launching a browser with this URL
logging in using userid and password
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
}
}
});
精彩评论