Trying to Download document and display image using API , token issues

Hello, I am embedding a search tool in my webapp that makes API calls to a mayan instance .

It is a angularjs app and all communication with the mayan API is via $http(ajax) calls

I can search and get the results. This works fine because i can create the request with the correct auth header info.

My Two issues are: (both are because the request is made without the auth token)

  1. nice to have… Would like to show the image from the response , but the img src requires the auth token and img src you can not do anything with the header request.

  2. when clicking on the link provided by the response to download the document , the auth token is also needed.

Anyone doing something like the and solved this issue?

thanks for any help