I want to be able to download a file from an API call. For argument's sake, let's say it's an automagically generated PDF file.
I have two problems:
- Anchor tags can't add
Authorization
headers to the request, onlyXHR
can. XHR
requests cannot download files.
My solution is to write my API with an [AllowAnonymous]
end point in it, which takes the access_token
as a parameter. I then validate the access token by hand and return a 401 or stream the PDF.
Is there a better solution than this or, if this is the best solution, how do I validate the access_token
within the API?