Mixin-Authorization

Build Status codecov npm version downloads

:fireworks: Authorization Mixin for Barktler

Install

yarn add @barktler/mixin-authorization
# Or
npm install @barktler/mixin-authorization --save

Bearer Authorization

import { createBearerAuthorizationMixin } from "@barktler/mixin-authorization";
import { YourAPI } from "somewhere";

const api: YourAPI = new YourAPI();
api.useMixin(createBearerAuthorizationMixin({
    getTokenFunction: async () => getYourToken(),
}));

Basic Authorization

import { createBasicAuthorizationMixin } from "@barktler/mixin-authorization";
import { YourAPI } from "somewhere";

const api: YourAPI = new YourAPI();
api.useMixin(createBasicAuthorizationMixin({
    getTokenFunction: async () => getYourToken(),
    base64: true, // default true, false for not encode
}));

Documents

See Barktler Documents.