cordova-plugin-inappbrowser
cordova-plugin-inappbrowser copied to clipboard
feat(android,ios): add request headers support
Platforms affected
android, ios
What does this PR do?
add request headers support
What testing has been done on this change?
automated test still working test using headers in my app
closes #361 replaces #115
Something is broken with the formatting:
npm run eslint
> [email protected] eslint /home/travis/build/apache/cordova-plugin-inappbrowser
> node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests
/home/travis/build/apache/cordova-plugin-inappbrowser/www/inappbrowser.js
118:1 error Expected indentation of 8 spaces but found 2 tabs indent
118:2 error Unexpected tab character no-tabs
118:29 error Trailing spaces not allowed no-trailing-spaces
119:1 error Expected indentation of 8 spaces but found 2 tabs indent
119:2 error Unexpected tab character no-tabs
120:1 error Expected indentation of 12 spaces but found 3 tabs indent
120:2 error Unexpected tab character no-tabs
121:1 error Expected indentation of 16 spaces but found 4 tabs indent
121:2 error Unexpected tab character no-tabs
121:51 error A space is required after ',' comma-spacing
122:1 error Expected indentation of 12 spaces but found 3 tabs indent
122:2 error Unexpected tab character no-tabs
122:4 error Closing curly brace does not appear on the same line as the subsequent block brace-style
123:1 error Expected indentation of 12 spaces but found 3 tabs indent
123:2 error Unexpected tab character no-tabs
124:1 error Expected indentation of 16 spaces but found 4 tabs indent
124:2 error Unexpected tab character no-tabs
124:22 error Trailing spaces not allowed no-trailing-spaces
125:1 error Expected indentation of 16 spaces but found 4 tabs indent
125:2 error Unexpected tab character no-tabs
126:1 error Expected indentation of 20 spaces but found 5 tabs indent
126:2 error Unexpected tab character no-tabs
127:1 error Expected indentation of 24 spaces but found 6 tabs indent
127:2 error Unexpected tab character no-tabs
127:32 error A space is required after ',' comma-spacing
127:52 error A space is required after ',' comma-spacing
127:72 error A space is required after ',' comma-spacing
128:1 error Expected indentation of 24 spaces but found 6 tabs indent
128:2 error Unexpected tab character no-tabs
128:60 error A space is required after ',' comma-spacing
128:80 error A space is required after ',' comma-spacing
128:100 error A space is required after ',' comma-spacing
129:1 error Expected indentation of 24 spaces but found 6 tabs indent
129:2 error Unexpected tab character no-tabs
130:1 error Expected indentation of 28 spaces but found 7 tabs indent
130:2 error Unexpected tab character no-tabs
131:1 error Expected indentation of 24 spaces but found 6 tabs indent
131:2 error Unexpected tab character no-tabs
131:15 error Multiple spaces found before '{' no-multi-spaces
132:1 error Expected indentation of 28 spaces but found 7 tabs indent
132:2 error Unexpected tab character no-tabs
132:28 error Strings must use singlequote quotes
133:1 error Expected indentation of 24 spaces but found 6 tabs indent
133:2 error Unexpected tab character no-tabs
134:1 error Expected indentation of 24 spaces but found 6 tabs indent
134:2 error Unexpected tab character no-tabs
134:33 error Strings must use singlequote quotes
134:45 error Trailing spaces not allowed no-trailing-spaces
135:1 error Expected indentation of 20 spaces but found 5 tabs indent
135:2 error Unexpected tab character no-tabs
136:1 error Expected indentation of 16 spaces but found 4 tabs indent
136:2 error Unexpected tab character no-tabs
137:1 error Expected indentation of 12 spaces but found 3 tabs indent
137:2 error Unexpected tab character no-tabs
138:1 error Expected indentation of 8 spaces but found 2 tabs indent
138:2 error Unexpected tab character no-tabs
✖ 56 problems (56 errors, 0 warnings)
35 errors, 0 warnings potentially fixable with the `--fix` option.
Note the last line, use npm run eslint --fix to fix most of those, then run npm run eslint again and fix manually. Then commit and push the result.
Looking for the same thing, will this become a feature in the short term?
I would like this feature as well. Any ETAs on this?
You can help by testing this locally (via the fork of @al1lhomme that contains these changes) and reporting back if it worked as expected.
Could I ask for progress? This feature is all I need to download any type of files from my server with authentication Header.
@janpio Just merged this into our fork and it seems to be working. It sends headers on the first request and on page reload. Tested on iOS and Android. Did not test using IAB's WKWebView mode.
This seems the same as PR #115 - but 3 years newer with fewer conflicts.
If this feature will allow us to override the User-Agent header, it would fulfill our feature request #502
Resolved the conflict.
Have to test this for both platforms, and on iOS for both webview types.
Someone have a page handy that shows the headers that were used to call it? Then it should be pretty simple to create a test app.
We should probably also try to add this to the tests somehow.
Someone have a page handy that shows the headers that were used to call it?
https://postman-echo.com/headers
Any update on this? I really hope we're not waiting on @al1lhomme because it looks like he hasn't been on github for 9 months.
We will have to find solutions to the comments that are open here. Some questions regarding the code, no new tests, no tested yet.
Anyone who wants to jump in and is not a contributor here (who can edit the fork directly) can just fork at https://github.com/al1lhomme/cordova-plugin-inappbrowser and then create a new PR to this repo and let us know here via a comment.
how can i use the version with custom headers?
Hi, I have tested the PullRequest in Android and it works ok. I have to add a new header to inappbrowser due to the fact that Google will block Google Sign In on January 4, 2021 from embedded browser frameworks. https://developers.googleblog.com/2020/08/guidance-for-our-effort-to-block-less-secure-browser-and-apps.html
Surprisingly, adding the new header "Google-Accounts-Check-OAuth-Login:true", Google Sign seems to be working. I am using browserTarget: '_blank'
I have tested and used the PullRequest in Android and iOS. Headers are working.
I have tested and used the PullRequest in Android and iOS. Headers are working.
Doesn't work for me. Tested with Cordova Android 9.0.0. Made all changes in InAppBrowser.java, inappbrowser.js and index.js By the way: I have 3 files with name InAppBrowser.java - which one should I edit?
Any news about this PR?
Can confirm this works on Android 10, we did not try to patch iOS because our ionic wrapper uses SafariWebviewController and not InAppBrowser
thx @al1lhomme
Helllo guys, any news on this PR? It's been pending since 2018... Being able to pass headers is quite important and useless for several cases...