Easily add OAuth 1.0a signing to your axios client
npm install axios-oauth-1.0aEasily add OAuth 1.0a signing to your axios client
npm i axios-oauth-1.0a
or
yarn add axios-oauth-1.0a
For use in the browser, you'll need to configure buffer and crypto support polyfills and fallback modules. See
resolve.fallback and
How To Polyfill Buffer With WebPack v5 for more information.
* The hashing function to use for the oauth_signature value
* Available values are: HMAC-SHA1, HMAC-SHA256
* Default value is HMAC-SHA256
* When true, always try to hash the body and include the hash in the signature
* When false, never try to calculate oauth_body_hash
* When 'auto', calculate oauth_body_hash on PUT or POST requests that have a body
* The Consumer Key value
* An optional value to set the OAuth 1.0 realm
* The Consumer Secret value
* The Access Token value
* An optional value to specify the access token secret
* An optional value to set the callback url
* An optional value to set the oauth verifier
To sign your axios requests using OAuth 1.0a:
``js
import addOAuthInterceptor from 'axios-oauth-1.0a';
// Create a client whose requests will be signed
const client = axios.create();
// Specify the OAuth options
const options = {
algorithm: 'HMAC-SHA1',
key: 'xxx',
secret: 'yyy',
};
// Add interceptor that signs requests
addOAuthInterceptor(client, options);
``
* RFC5849 - The OAuth 1.0 Protocol
* Axios Interceptors
See github releases