Iam trying to open one website url on the webview.But iam getting Error "403 forbidden access is denied".How fix this issue? Iam using the wifi connection and i also written internet permission in the manifest file. Like this How to solve this issue? Thanks for any help.
Asked
Active
Viewed 1.2k times
2
-
1Can you open that url in a browser? – Nizam Jul 22 '13 at 12:32
-
Paste the `AndroidManifest` here, as well as the code you use to open the page (Only that part). – g00dy Jul 22 '13 at 12:33
-
This answer gives a good hint about ssl and webviews: http://stackoverflow.com/a/5978391/891479 – L. G. Jul 22 '13 at 12:43
2 Answers
1
For anyone having the same issue in 2018. Try the below code and read my explanation.
There are few possible reasons about why you can get the 403 Forbidden error. I have identified 2 of them.
- It is an SSL issue.
- Your
User Agent
is blocked by the website.
Here is how you set the SSL configurations. Here the newsWebView
is a WebView
.
newsWebView.setWebViewClient(new WebViewClient() {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
public void onPageFinished(WebView view, String url) {
}
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
}
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
// TODO Auto-generated method stub
super.onReceivedSslError(view, handler, error);
handler.proceed();
}
});
This is how you set the User Agent
. I am setting the Google Chrome agent, the one we normally find in our phones.
newsWebView.getSettings().setUserAgentString("Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>");

PeakGen
- 21,894
- 86
- 261
- 463
-1
Try Adding this code on your Web Client:
public void onReceivedSslError(final WebView view, final SslErrorHandler handler, final SslError error) {
// TODO Auto-generated method stub
super.onReceivedSslError(view, handler, error);
handler.proceed();
}
It will allow webview to load the page , in case of SSL error with website

Nargis
- 4,687
- 1
- 28
- 45
-
It is working now, but webview asking like Complete action using Browser, Opera Mini? – joe Jul 22 '13 at 13:07
-
-
-
-
To open url in default browser, opem google chrome or opera mini browser and paste the url, it shall open it. – Nargis Jul 23 '13 at 04:57
-