Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
@scienta/axios-oauth2
Advanced tools
Readme
This library makes oauth with axios easy. There is a oauth-client, a token interceptor and caching.
You can use only the client, or combine it with the token interceptor and caching.
import axios from 'axios';
import {clientFactory} from '@scienta/axios-oauth';
const client = clientFactory(axios.create(), {
url: 'https://oauth.com/2.0/token',
grant_type: 'client_credentials',
client_id: 'foo',
client_secret: 'bar',
scope: 'baz'
});
const auth = await client(); // => { "access_token": "...", "expires_in": 900, ... }
import axios from 'axios';
import {clientFactory, interceptorFactory} from '@scienta/axios-oauth';
const axiosInstance = axios.create();
axiosInstance.interceptors.request.use(
interceptorFactory(clientFactory(axiosInstance, {
url: 'https://oauth.com/2.0/token',
grant_type: 'client_credentials',
client_id: 'foo',
client_secret: 'bar',
scope: 'baz'
}))
);
axiosInstance.get('https://oauth.com/2.0/protectedResource')
import axios from 'axios';
import {clientFactory, interceptorFactory, LockingTokenCache} from '@scienta/axios-oauth';
const axiosInstance = axios.create();
axiosInstance.interceptors.request.use(
interceptorFactory(
clientFactory(axiosInstance, {
url: 'https://oauth.com/2.0/token',
grant_type: 'client_credentials',
client_id: 'foo',
client_secret: 'bar',
scope: 'baz'
}),
new LockingTokenCache()
)
);
axiosInstance.get('https://oauth.com/2.0/protectedResource')
The LockingTokenCache
class uses a separate library for locking and caching.
Locking cache is a caching-library suited for simple and complex locking while caching.
Locking with caching ensures that only one request is executed to request a token.
Want to know more? @scienta/locking-cache.
FAQs
Cacheable token interceptor for oauth requests with axios
The npm package @scienta/axios-oauth2 receives a total of 413 weekly downloads. As such, @scienta/axios-oauth2 popularity was classified as not popular.
We found that @scienta/axios-oauth2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).