@storyous/auth
v1.2.0
Published
```typescript import { createSaltAuth } from '@storyous/auth';
Downloads
11
Keywords
Readme
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()