Giter Site home page Giter Site logo

socheatsok78 / axios-authorization Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 115 KB

Axios authorization plugin ๐ŸŽซ

Home Page: https://npm.im/@socheatsok78/axios-authorization

License: MIT License

JavaScript 28.08% TypeScript 71.92%
axios axios-plugin axios-ecosystem

axios-authorization's Introduction

@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.

axios-authorization's People

Contributors

socheatsok78 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

axios-authorization's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.