openUrl with custom headers



  • I need to use openURL to fetch PDF that is behind the authorization. The target URL is not directly the PDF-file, but a PHP script that checks Bearer token from request’s Authorization headers, and then provides the file.

    Is there any way to provide custom headers in openURL call?

    I could do the same by axios, native window.open, etc, but this also must work with Cordova app and I believe the openUrl handles all the quirks that are involved.

    Suggestions?

    Currently I have a workaround with some hacks in backend to check token from query string if not present in headers.

    if (this.$q.platform.is.cordova) {
         openURL('/target-url/pdf/' + token);
     } else {
         this.$http.get('/target-url/pdf', { 
            responseType: 'arraybuffer',
            headers:  {
                'Authorization': 'Bearer ' + token,
           }
        });
    }
    


  • This post is deleted!