Github user RafaelKr commented on the issue: https://github.com/apache/cordova-plugin-inappbrowser/pull/221 This is awesome! But can you please change the function `processDownload` like this? ```Java import android.webkit.CookieManager; [...] protected void processDownload() { final String url = InAppBrowserDownloads.this.url; final String cookie = CookieManager.getInstance().getCookie(url); final String filename = URLUtil.guessFileName(url, InAppBrowserDownloads.this.contentDisposition, InAppBrowserDownloads.this.mimetype); DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.addRequestHeader("Cookie", cookie); request.addRequestHeader("User-Agent", InAppBrowserDownloads.this.userAgent); request.addRequestHeader("Referer", url); request.allowScanningByMediaScanner(); // Notify client once download is completed! request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); try { DownloadManager dm = (DownloadManager) plugin.cordova.getActivity().getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); // This is important! intent.addCategory(Intent.CATEGORY_OPENABLE); // CATEGORY.OPENABLE intent.setType("*/*"); // any application, any extension Toast.makeText(plugin.cordova.getActivity().getApplicationContext(), "Downloading File '" + filename + "'", Toast.LENGTH_LONG).show(); } catch (Exception exception) { Toast.makeText(plugin.cordova.getActivity().getApplicationContext(), "Error downloading file, missing storage permissions", Toast.LENGTH_LONG).show(); exception.printStackTrace(); } } ``` This passes the cookies from the WebView to the DownloadManager, so you're able to download files from locations where you need to be signed in. I also cleaned up the code a little bit. The important code I added is this part: ```Java import android.webkit.CookieManager; [...] final String cookie = CookieManager.getInstance().getCookie(url); // Note that I defined the variable url before [...] request.addRequestHeader("Cookie", cookie); request.addRequestHeader("User-Agent", InAppBrowserDownloads.this.userAgent); request.addRequestHeader("Referer", url); [...] ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org For additional commands, e-mail: dev-h...@cordova.apache.org