goshippo / shippo-node-client

Shipping API Node.js library (USPS, FedEx, UPS and more)
https://goshippo.com/docs
MIT License
136 stars 54 forks source link

How to use OAuth with the SDK? #85

Closed Akumzy closed 1 year ago

Akumzy commented 1 year ago

How can I use the OAuth https://goshippo.com/docs/oauth/ with the SDK?

jfriedr commented 1 year ago

Once you have gotten the oauth bearer token for your customers via the link you shared you can use that within the client sdk code. Once you have the user's Oauth token the client sdk detects the token type and makes the required changes to the Authorization header. You can see this in the code of the repo here:

https://github.com/goshippo/shippo-node-client/search?q=Bearer

Keep in mind that the above code simply changes the header so that API calls made with the Oauth token go with the "Bearer" token type rather than the ShippoToken which is used for regular API calls.