Closed danschumann closed 4 years ago
Oh yea, I switched so that I can just pass the oauth token to the initial shippo
ShippoResource = require('shippo/lib/Resource')
getHeaderOriginal = ShippoResource::_get_headers
ShippoResource::_get_headers = (data) ->
output = getHeaderOriginal.apply this, arguments
if @_shippo.get('token').match(/^oauth/)
output.Authorization = 'Bearer ' + @_shippo.get('token')
return output
shippo = require('shippo')('oauth.abcasdflsjafdklj...)
According to https://goshippo.com/docs/oauth/ , you must use "Bearer" instead of "ShippoToken" in the Authorization header.
So, a quick hack:
(Mind the coffee script)
Shall I make a PR to implement something like this?
Would it be better off to just allow
shippo = require('shippo')('oauth.abc1234')
And detect the string starting with oauth... and therefore simply use Bearer instead of ShippoToken?