1.0.5 • Published 9 months ago

@socheatsok78/axios-authorization v1.0.5

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@socheatsok78/axios-authorization

Axios authorization plugin 🎫

@npm license

Features

  • Add support for BasicToken
  • Add support for BearerToken
  • Add support for Oauth 1.0
  • Add support for Oauth 2.0
  • Add support for Microsoft NTLM
  • Add support for AWS IAM v4

Install

npm install @socheatsok78/axios-authorization
# or
yarn add @socheatsok78/axios-authorization

Usage

import axios from 'axios'
import { useAuthorization } from '@socheatsok78/axios-authorization'

// Register the plugin
useAuthorization(axios)

// Create token object
const token = axios.credentials.create('Bearer', { token: 'your-bearer-token' })

// Set the Authorization token to the request header
axios.credentials.store(token) 

// Remove the Authorization token from the request header
axios.credentials.clear()

Create a Bearer token

import { BearerToken } from '@socheatsok78/axios-authorization'

// Create Bearer token object
const token = axios.credentials.create('Bearer', { token: 'your-bearer-token' })

// or

const token = new BearerToken({
    token: 'your-bearer-token',
    prefix: 'Bearer' // optional
})

// Set the Authorization token to the request header
axios.credentials.store(token) 

Create a Basic token

import { BasicToken } from '@socheatsok78/axios-authorization'

// Create Basic token object
const token = axios.credentials.create('Basic', {
    username: 'your-username',
    password: 'your-secure-password'
})

// or

const token = new BasicToken({
    username: 'your-username',
    password: 'your-secure-password'
})

// Set the Authorization token to the request header
axios.credentials.store(token) 

License

Licensed under the MIT License.

1.0.2

9 months ago

1.0.1

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.0

3 years ago

1.0.0-beta.6

3 years ago

1.0.0-beta.3

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.5

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.1

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago