Closed StephanMeijer closed 5 years ago
You can set headers directly on the devour instance, does that work for you?
const jsonApi = new JsonApi({apiUrl: 'http://your-api-here.com'})
// Append headers to every request
jsonApi.headers['Authorization'] = `Bearer ${token}`
that works, but why is Basic auth being handled as a first class citizen, but Bearer is not?
The underlying library axios treats basic as first-class citizen. https://github.com/axios/axios
Should be easy enough to implement bearer token.
https://github.com/twg/devour/blob/master/src/middleware/json-api/req-http-basic-auth.js
It would be nice to have a utility method to allow for Bearer tokens.
I wrote an implementation for this: https://github.com/twg/devour/pull/200
This has been merged.
Support for authentication through for example jwt tokens:
Authorization: Bearer ...........
Will write this myself