Auth0 Authorization Extension API client library
npm install @natgeosociety/auth0-authorization
Use this client to access the Auth0 Authorization Extension API.
import { AuthorizationClient } from '@natgeosociety/auth0-authorization';
const authorization = new AuthorizationClient({
clientId: `${CLIENT_ID}`,
clientSecret: `${CLIENT_SECRET}`,
domain: `${TENANT}.auth0.com`,
extensionUrl: `https://${TENANT}.us.webtask.io/xxx/api`,
});
Behind the scenes the client obtains an access token, caches it, and automatically refreshes it if it expires.
Each method returns a promise.
const groups = await authorization.getGroups();
TypeScript types are included.
import { IAuth0AuthorizationApiGroup } from '@natgeosociety/auth0-authorization';
let group: IAuth0AuthorizationApiGroup;
All tests run against a live Auth0 tenant instance.
First you need to set up a .env
file containing the Auth0 configuration. Here is an example .env
that includes
all non-secret values:
cat <<'EOF' > .env
AUTH0_DOMAIN=xxx
AUTH0_CLIENT_ID=xxx
AUTH0_CLIENT_SECRET=xxx
AUTH0_EXTENSION_URL=xxx
EOF
env $(cat .env | xargs) npm test
npm run testbuild
env $(cat .env | xargs) node_modules/.bin/ava test/[test-name].spec.js
Logging in tests should use ava t.log
instead of console.log
.
Those logs will appear only when running ava in verbose mode:
env $(cat .env | xargs) node_modules/.bin/ava test/[test-name].spec.js --verbose