https://github.com/uswitch/auth0-access-token
Fetches an acess token from auth0.
https://github.com/uswitch/auth0-access-token
Last synced: over 1 year ago
JSON representation
Fetches an acess token from auth0.
- Host: GitHub
- URL: https://github.com/uswitch/auth0-access-token
- Owner: uswitch
- Created: 2021-03-15T10:54:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-28T18:59:53.000Z (almost 3 years ago)
- Last Synced: 2025-02-08T04:29:13.734Z (over 1 year ago)
- Language: TypeScript
- Size: 29.3 KB
- Stars: 0
- Watchers: 19
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# auth0-access-token
## Installation and Usage
`npm install --save auth0-access-token`
Grab your credentials from Auth0. You can find them on your Auth0 application settings page.
```javascript
import AuthClient from 'auth0-access-token'
const authClient = new AuthClient({
audience: 'YOUR_AUDIENCE'
clientId: 'YOUR_CLIENT_ID'
clientSecret: 'YOUR_CLIENT_SECRET'
url: 'YOUR_AUTH0_URL/oauth/token'
}
})
```
And then you can get your token with `authClient.getToken()`
Here's an example of how to get a token to use on a subsequent http request:
```javascript
const fetchSecureData = async () => {
const token = await authClient.getToken()
axios({
method: 'POST',
url: '',
headers: { authorization: `Bearer ${token}` },
data: {...}
})
}
```
## API
| Interfaces | Description | Params |Returns
| --- | --- | --- | --- |
| `AuthClient` | Constructor method, use `new` keyword | `{audience, clientId clientSecret, url }` |client instance
| `client.getToken` | Fetches token | empty |`Promise` |
## Token request flow

## Development
After you've made your changes to the package and pushed your branch, run:
`npm version [patch|minor|major]`
This will automatically bump up the version and push a new tag. If this is not done, the build will fail because npm doesn't allow publishing the same version twice. Make sure to follow semantic versioning.
Lastly, merge your PR and that check the drone build. If all goes well, it should automatically publish the new version to `npm`.
### TODO:
Make it easier to test changes locally