client-js
client-js copied to clipboard
Allow overriding the Authorization header
trafficstars
In our project we need a separate token for mutations. I expected to be able to override the Authorization header like this:
const headers = {'Authorization': `Bearer ${state.token}`};
return client.update(resource, {headers});
However, the tokenResponse takes presence.
In our project we need a separate token for mutations
Can you explain how that works? Do you get different permissions based on the token you use (but still only use one token for everything), or do you expect to somehow work with multiple tokens depending on what you are about to do?
It seems to me that your proposed change would lock the authorization header to whatever is provided in requestOptions (if any). In other words, imagine the following sequence:
- You authorize and get an access token and a refresh token
- You use your app for a while and the access token expires
- You make another
requestand pass your ownauthorizationheader as an option- At that moment the library would detect the expired access token and fetch new one
- Then, despite having a fresh access token, your
authorizationheader will override it
Is that the intended behavior here?