Saturday, April 1, 2017

Download file using token based API

I'm creating a web application with Vue.js(front end) + Laravel(back end) and I structured the whole app to communicate with the back end through api routes. The requests pass through a middleware for authentication using a token (passport in Laravel). At some point I need to download some files, but I wouldn't know how to make it happend because I have no way to identificate or authenticate the user though web routes. I could send byte data from the API through an ajax request but then it would be difficult to make the user download the file from the javascript (at least it would be hard to make things work on every browser).

So what's the best approach to this problem?



via stacofuori

Advertisement