https://github.com/socheatsok78/axios-authorization
Axios authorization plugin 🎫
https://github.com/socheatsok78/axios-authorization
axios axios-ecosystem axios-plugin
Last synced: about 1 month ago
JSON representation
Axios authorization plugin 🎫
- Host: GitHub
- URL: https://github.com/socheatsok78/axios-authorization
- Owner: socheatsok78
- License: mit
- Created: 2021-07-23T11:18:31.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-06-05T15:13:55.000Z (12 months ago)
- Last Synced: 2025-04-06T05:53:28.844Z (about 2 months ago)
- Topics: axios, axios-ecosystem, axios-plugin
- Language: TypeScript
- Homepage: https://npm.im/@socheatsok78/axios-authorization
- Size: 112 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @socheatsok78/axios-authorization
Axios authorization plugin 🎫
[![@npm][npm-badge]][npm-url]
[![license][license-badge]](LICENSE)## Features
- [x] Add support for `BasicToken`
- [x] 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
```sh
npm install @socheatsok78/axios-authorization
# or
yarn add @socheatsok78/axios-authorization
```## Usage
```js
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**
```js
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**```js
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](LICENSE).
[npm-badge]: https://img.shields.io/npm/dw/@socheatsok78/axios-authorization
[npm-url]: https://npm.im/@socheatsok78/axios-authorization
[license-badge]: https://img.shields.io/github/license/socheatsok78/axios-authorization