I am getting response from my server with native google+ sign-in oauth2 token , and i am setting cookie:
String cookieSessionString = "JSESSIONID" + "=" + i.getStringExtra("C_session_id");
String cookieEmailString = "useremail" + "=" + i.getStringExtra("C_user_email");
String cookieNameString = "username" + "=" + i.getStringExtra("C_user_name");
String cookieUseridString = "userid" + "=" + i.getStringExtra("C_user_id");
CookieManager cookieManager = CookieManager.getInstance();
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(webView.getContext());
cookieManager.setCookie("mydomain.co", cookieSessionString);
cookieManager.setCookie("mydomain.co", cookieEmailString);
cookieManager.setCookie("mydomain.co", cookieNameString);
cookieManager.setCookie("mydomain.co", cookieUseridString);
cookieManager.setAcceptCookie(true);
cookieSyncManager.getInstance().sync();
In webview I am calling:
webView.getSettings().setAppCacheEnabled(true);
WebViewDatabase.getInstance(this).clearHttpAuthUsernamePassword();
webView.getSettings().setDatabaseEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webSettings.getCacheMode();
webView.loadUrl(base_url);
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
startActivity(new Intent(MainActivity.this, NoDataActivity.class).putExtra("Activity", "Main.class"));
super.onReceivedError(view, errorCode, description, failingUrl);
}
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onLoadResource( WebView view, String url ){
CookieManager cookieManager = CookieManager.getInstance();
cookie = cookieManager.getCookie(url);
Log.d("ONloadResource","cookie is"+cookie);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setCookie(url, cookie);
progressBar.setVisibility(View.GONE);
progressBar.setProgress(100);
if (url.contains("/ccavResponseHandler.jsp")) {
webView.loadUrl("javascript:window.HTMLOUT.processHTML ('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
}
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
progressBar.setVisibility(View.VISIBLE);
progressBar.setProgress(5);
}
});
And also tried to send the headers like:
extraHeaders.put("JSESSIONID", i.getStringExtra("C_session_id"));
extraHeaders.put("username", i.getStringExtra("C_user_name"));
extraHeaders.put("useremail", i.getStringExtra("C_user_email"));
webView.loadUrl(url, extraHeaders);`
Didn't worked in webview login ..!
Can any one help me on this how can I login with session id and user-email, id in webview in my domain URL.