简体   繁体   中英

How to make HTTP Request with authentication info from WebView in Android?

I am trying to extract some info from a website which requires login to access said page. I created a webview to allow to user to log in first.

The question is, how to use the authorization info from that webview in other HTTP requests?

You can extract the cookies from the page and use them in later requests.

@Override
public void onPageFinished(WebView view, String url){
    String cookies = CookieManager.getInstance().getCookie(url);
    Log.d(TAG, "All the cookies in a string:" + cookies);
}

see more here: Android - extracting cookies after login in webview

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM