@wisemen/vue-core-auth
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Wisemen vue-core OAuth Client

This package provides a simple way to authenticate with an OAuth2 server.

Installation

pnpm add @wisemen/vue-core-oauth-client

Usage

OAuth2VueClient

Create a new file auth.lib.ts and add the following code:

import { OAuth2VueClient } from '@wisemen/vue-core-auth'
import axios from 'axios'

import {
  API_AUTH_URL,
  API_CLIENT_ID,
  API_CLIENT_SECRET,
} from '@/constants/environment.constant.ts'

export const oAuthClient = new OAuth2VueClient({
  clientId: API_CLIENT_ID,
  axios,
  clientSecret: API_CLIENT_SECRET,
  tokenEndpoint: `${API_AUTH_URL}/token`,
})

ZitadelClient

Create a new file auth.lib.ts and add the following code:

import { ZitadelClient, useAxiosFetchStrategy, localStorageTokensStrategy } from '@wisemen/vue-core-auth'
import axios from 'axios'

import {
  AUTH_BASE_URL,
  AUTH_CLIENT_ID,
  AUTH_ORGANIZATION_ID,
  CURRENT_ENVIRONMENT,
} from '@/constants/environment.constant.ts'

export const oAuthClient = new ZitadelClient({
  clientId: AUTH_CLIENT_ID,
  organizationId: AUTH_ORGANIZATION_ID,
  fetchStrategy: new AxiosFetchStrategy(axios),
  tokensStrategy: new LocalStorageTokensStrategy(), // Optional, defaults to localStorage 
  baseUrl: AUTH_BASE_URL,
  loginRedirectUri: `${window.location.origin}/auth/callback`,
  offline: CURRENT_ENVIRONMENT === 'e2e',
  postLogoutRedirectUri: `${window.location.origin}/auth/logout`,
})

Readme

Keywords

none

Package Sidebar

Install

npm i @wisemen/vue-core-auth

Weekly Downloads

242

Version

2.0.1

License

MIT

Unpacked Size

33.9 kB

Total Files

7

Last publish

Collaborators

  • wouter.appwise
  • kobe-kwanten-wisemen
  • jorenvandeweyer
  • robbe95
  • fullmetaljs
  • maartensijmkens
  • wisemen-sysops
  • peetha
  • daanpersoons
  • jonasvannieuwenhuijsen
  • yuhanghu
  • jonasbeckers