Support Bearer Tokens (e.g. JWT)
StephanMeijer opened this issue · 6 comments
StephanMeijer commented
Support for authentication through for example jwt tokens:
Authorization: Bearer ...........
Will write this myself
spiderbites commented
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}`
StephanMeijer commented
that works, but why is Basic auth being handled as a first class citizen, but Bearer is not?
billxinli commented
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
Auspicus commented
It would be nice to have a utility method to allow for Bearer tokens.
kevincoenegrachts commented
I wrote an implementation for this: #200
Auspicus commented
This has been merged.