https://github.com/zentered/auth0-get-token
Auth0 library to retrieve accessTokens for integration testing
https://github.com/zentered/auth0-get-token
Last synced: 5 months ago
JSON representation
Auth0 library to retrieve accessTokens for integration testing
- Host: GitHub
- URL: https://github.com/zentered/auth0-get-token
- Owner: zentered
- License: mit
- Created: 2019-06-14T12:19:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-11-02T14:56:30.000Z (over 6 years ago)
- Last Synced: 2025-09-30T00:44:25.025Z (9 months ago)
- Language: JavaScript
- Size: 174 KB
- Stars: 1
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/heneise/auth0-get-token)
# Auth0 Token
Getting an access token for your API.
This can be used for integration testing, to dynamically obtain tokens when needed. No hardcoded accessTokens, no mocking.
## Auth0 Setup

- In your [Auth0 Dashboard](https://manage.auth0.com/dashboard/) create a new API if you didn't already do so (you can copy the API Identifier right away and paste into the config)
- Head over to "Applications", there should be a Machine-to-Machine application with the same name as your API and "(Test Application)"
- Click on the Test Application to see the settings
- In the very bottom, click "Show Advanced Settings"
- Go to the tab "Grant Types"
- Select "Password" (this enables user/password requests for this library)
## Usage
From the auth0 API, copy:
- API IDENTIFIER (ie. "auth0-get-token") as `AUTH0_AUDIENCE`
From the auth0 Application, copy:
- Domain as `AUTH0_BASE_URL` (add `https://`)
- Client ID as `AUTH0_CLIENT_ID`
- Client Secret as `AUTH0_CLIENT_SECRET`
Then, you can retrieve a token:
const getToken = require('auth0-get-token')
const tokens = await getToken('username', 'test-password')