Document preview and download using API links

Anything concerning integration via the REST API
Post Reply
heyoh
Posts: 1
Joined: Sun Dec 01, 2019 9:39 pm

Document preview and download using API links

Post by heyoh » Sun Dec 01, 2019 9:44 pm

Hello,

I try to preview and download documents using the rest API. Everything works perfectly with token auth. I have a React app. Unfortunately, it's not possible to set the auth header with HTML img tag and regular link tags. I've tried to attach token with URL like <img src="http://api.com/image-link?&token=realtoken"> but it doesn't work. I couldn't find a way to solve this problem. How can I preview or download a doc outside of the Mayan EDMS admin panel using just the REST API?

m42e
Posts: 5
Joined: Fri Oct 11, 2019 8:21 am

Re: Document preview and download using API links

Post by m42e » Mon Dec 02, 2019 8:51 pm

Just looking Ford the first result at stackoverflow.com, which looks promising

https://stackoverflow.com/questions/236 ... ms-to-pass

User avatar
rosarior
Posts: 457
Joined: Tue Aug 21, 2018 3:28 am

Re: Document preview and download using API links

Post by rosarior » Wed Dec 11, 2019 3:13 am

It is not advisable to add the API token as part of the URL of images. The token will be visible upon network inspection even when using HTTPS. This is why API tokens and other authentication information is sent over the header which is encrypted or as part of the session like the answer @m42e posted.

Post Reply