6

I am using cordova inappbrowser Plugin.

When I opened URL in any mobile browser below popup come but when same url I tried to open through inappbrowser I am not getting this authentication popup. Its showing 401 authentication error directly.

enter image description here

Why this behavioral change? IS there anything I have to provide to get same behavior like browser?

Or is there I can directly pass username and password? So how can I implement basic authentication?

I have tried with form submission way also.

<form name="frm" id="frm" method="POST" action="http://sample.xyz/test">
   <input type="hidden" name="username" id="username" value="abc" />
   <input type="hidden" name="password" id="password" value="xyz" />
</form> 

Also I have tried below also which I got by googling.

window.open("http://abc:[email protected]/test");

help me out.

Suhas Gosavi
  • 2,170
  • 19
  • 40

2 Answers2

-1

That is not a login form from any page. It is an htaccess(or similar) authentication.

So, you can't simply supply credentials via a login form.

There is a discussion regarding this in Google Groups

The method you tried

window.open("http://'abc':'xyz'@sample.xyz/test");

Change it to

window.open("http://abc:[email protected]/");

Or

window.open("http://abc:[email protected]/test");

This will authenticate you to the site.

Sagar V
  • 12,158
  • 7
  • 41
  • 68
-1

InAppBrowser by default works with url only.

If your link require sending parameters via POST you should try this approche:

            var postParams = {
                "param1": param,
                "param2": param2
            };

            var pageContent = '<html><head></head><body><form id="loginForm" action="' + siteAddress + '" method="post">' +
                '<input type="hidden" name="postParams" value="' + encodeURI(JSON.stringify(postParams)) + '">' +
                '</form> <script type="text/javascript">document.getElementById("loginForm").submit();</script></body></html>';
            var pageContentUrl = 'data:text/html;base64,' + btoa(pageContent);

            ref = window.open(pageContentUrl, '_blank', 'location=no,zoom=no,hidden=yes,disallowoverscroll=no,toolbar=no,clearcache=no,clearsessioncache=no');
fatalica
  • 117
  • 9