Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-oauth-client

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-oauth-client

OAuth 2.0 client utils for axios

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.5K
decreased by-80.9%
Maintainers
1
Weekly downloads
 
Created
Source

axios-oauth-client

OAuth 2.0 client utils for axios

Installation

With NPM:

$ npm install --save axios-oauth-client axios

With Yarn:

$ yarn add axios-oauth-client axios

Axios OAuth 2.0 Client

Authorization Code grant

import axios from 'axios'
import oauth from 'axios-oauth-client'
const getAuthorizationCode = oauth.authorizationCode(
  axios.create(),
  'https://oauth.com/2.0/token', // OAuth 2.0 token endpoint
  'CLIENT_ID',
  'CLIENT_SECRET',
  'https://your-app.com/oauth-redirect' // Redirect URL for your app
)

const auth = await getAuthorizationCode('AUTHORIZATION_CODE', 'OPTIONAL_SCOPES')
// => { "access_token": "...", "expires_in": 900, ... }

Owner Credentials grant

import axios from 'axios'
import oauth from 'axios-oauth-client'
const getOwnerCredentials = oauth.ownerCredentials(
  axios.create(),
  'https://oauth.com/2.0/token', // OAuth 2.0 token endpoint
  'CLIENT_ID',
  'CLIENT_SECRET'
)

const auth = await getOwnerCredentials('USERNAME', 'PASSWORD', 'OPTIONAL_SCOPES')
// => { "access_token": "...", "expires_in": 900, ... }

Client Credentials grant

import axios from 'axios'
import oauth from 'axios-oauth-client'
const getClientCredentials = oauth.clientCredentials(
  axios.create(),
  'https://oauth.com/2.0/token',
  'CLIENT_ID',
  'CLIENT_SECRET'
)

const auth = await getClientCredentials('OPTIONAL_SCOPES')
// => { "access_token": "...", "expires_in": 900, ... }

Refresh Token grant

import axios from 'axios'
import oauth from 'axios-oauth-client'
const getRefreshToken = oauth.refreshToken(
  axios.create(),
  'https://oauth.com/2.0/token',
  'CLIENT_ID',
  'CLIENT_SECRET'
)

const auth = await getRefreshToken('REFRESH_TOKEN', 'OPTIONAL_SCOPES')
// => { "access_token": "...", "refresh_token": "...", "expires_in": 900, ... }

License

MIT

Keywords

FAQs

Package last updated on 28 Apr 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc