cordova-plugin-inappbrowser icon indicating copy to clipboard operation
cordova-plugin-inappbrowser copied to clipboard

adding support for passing request headers

Open al1lhomme opened this issue 6 years ago • 9 comments

In the #115 pull request, @sanketmehta7 proposed this feature but only for android and his pull request is blocked and not mergeable.

I am needing this support for one of my application both in android and ios.

One other point : @sanketmehta7 propose to encode headers in one unique string with the same encoding than the options argument : header1=value1,header2=value2. but in this encoding values cannot include commas or equals characters.

an other solution is needed to included any characters from headers.

al1lhomme avatar Dec 03 '18 08:12 al1lhomme

Sounds like a useful feature. We are always open for reviewing new Pull Requests!

janpio avatar Dec 03 '18 09:12 janpio

But is dead this issue?

gaiapuffo avatar May 13 '19 10:05 gaiapuffo

Thanks iharyan and lihuelg. You code changes help me in Android and worked fine. I am not sure why in iOS its still not working.

Here is my scenario.

I have 3 urls: entryURL basic Authentication validation URL successURL

  1. entry url environment.samlURL - example say: site1.com/mobile/index.html (samlURL) - I am passing authorization header
let authHeader:any={};
authHeader['Authorization'] = 'Basic ' + btoa(params.name + ':' + params.password);
const browser = this.iab.create(environment.samlURL, '_blank', { usewkwebview: 'yes', hidenavigationbuttons: 'yes', hideurlbar: 'no', location: 'yes', clearcache: 'yes', clearsessioncache: 'yes' }, authHeader); //passing authHeader to site1.com
  1. site1.com redirects with headers to samlSite for verifying authentication (idp-xxx.sss.com/samlverification...)

  2. on successful authentication samlsite redirects back to site1.com/mobile/success.html?successToken with successToken

     await browser.on('loadstart').subscribe(async (event) => {
       await browser.executeScript({ code: 'location.search.substring(1)' }).then(async (queryParams: any) => {
         if (queryParams && queryParams[0] !== '') {
           const urlParams = new URLSearchParams(queryParams[0]);
           const sToken = urlParams.get('successToken');
           if (sToken ) {
             resolve(sToken);
             browser.close();
           }
         }
       });
    

In android all works as expected, but in iOS navigation stops in second stage. I am able to see the headers getting passed to site1.com but redirection to idp basic authentication fails.. Is there anything in iOS code where redirection to different domain will stop??

any pointers will be very helpful.

SnpDeveloper avatar Dec 05 '20 16:12 SnpDeveloper

i don't understand why this feature is not yet merged ... it's basic and simple feature.

moxgeek avatar Aug 03 '21 14:08 moxgeek

I cant find any solutions for this case in web. Im searching 3 days any solutions for this case, to add Authorization position in header request and nothing was found. I´ve put some code in my backend that I don't rejoice, passing the Authorization on query param in url and the backend get the Authorization in the query params into the header.

thalesbarbosab avatar Dec 09 '21 18:12 thalesbarbosab

any update on this? Is this feature now added ?

hrishi-neo avatar Dec 27 '22 06:12 hrishi-neo

Can anyone take a look at the #1024 ? Different approach, using already present options, implementing headers and cookies. Cheers!

lubbo avatar Sep 26 '23 17:09 lubbo