# @socheatsok78/axios-authorization

> Axios authorization plugin 🎫

Latest version **1.0.5** (published 2023-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @socheatsok78/axios-authorization
pnpm add @socheatsok78/axios-authorization
yarn add @socheatsok78/axios-authorization
bun add @socheatsok78/axios-authorization
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-08-07 |
| First published | 2021-07-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 53.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Socheat Sok |
| Maintainers | andrewalex |

## Links

- npm: https://www.npmjs.com/package/@socheatsok78/axios-authorization
- Repository: git@github.com:socheatsok78/axios-authorization
- npm.io page: https://npm.io/package/@socheatsok78/axios-authorization

## Dependencies (2)

- [base-64](https://npm.io/package/base-64.md) ^1.0.0
- [@types/base-64](https://npm.io/package/@types/base-64.md) ^1.0.0

## Recent versions

- 1.0.5 (latest) — 2023-08-07
- 1.0.4 — 2023-08-07
- 1.0.3 — 2023-08-07
- 1.0.2 — 2023-08-07
- 1.0.1 — 2023-08-07
- 1.0.0 — 2021-10-20
- 1.0.0-beta.6 — 2021-08-06
- 1.0.0-beta.5 — 2021-07-27
- 1.0.0-beta.4 — 2021-07-27
- 1.0.0-beta.3 — 2021-07-27
- 1.0.0-beta.2 — 2021-07-23
- 1.0.0-beta.1 — 2021-07-23
- 0.1.1 — 2021-07-23
- 0.1.0 — 2021-07-23

## 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).

<!-- variables -->
[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

---
_Source: https://npm.io/package/@socheatsok78/axios-authorization · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
