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

1.2.0 • Public • Published

auth

Usage of saltAuth

import { createSaltAuth } from '@storyous/auth';

const config = {
    identityBaseUrl: 'https://identity.cloud.saltpay.co',
    clientId: process.env.SALTID_CLIENT_ID,
    clientSecret: process.env.SALTID_CLIENT_SECRET,
    redirectUris: ['https://login.storyous.com/api/auth/salt-id-callback'],
    customRequestTimeout: 10000
};

// see @storyous/logger
const log = initLogger(config.env, config.logging).module('saltAuth');

const saltAuth = createSaltAuth(config, log);

// During application bootstrapping,
// you have the option to set a timeout for the init function,
// allowing it to retry before throwing an error.
// If no timeout is specified, the default timeout of 30 seconds is used.
await saltAuth.init(20);

// authorize request to a service behind API Gateway
const accessToken = saltAuth.getAccessToken();
const headers = {
    'Authorization': `Bearer ${accessToken}`;
};

// get an additional OAuth client
const client = await saltAuth.createClient()

Readme

Keywords

none

Package Sidebar

Install

npm i @storyous/auth

Weekly Downloads

6

Version

1.2.0

License

ISC

Unpacked Size

31 kB

Total Files

15

Last publish

Collaborators

  • danieldadateya
  • nte-saltpay
  • mkoubik
  • storyous-user
  • vaclav.obornik
  • tymak
  • ivo.sofranek