# @heneise/auth0-get-token

> Getting an access token for your API

Latest version **1.0.1** (published 2019-06-17) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @heneise/auth0-get-token
pnpm add @heneise/auth0-get-token
yarn add @heneise/auth0-get-token
bun add @heneise/auth0-get-token
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-06-17 |
| First published | 2019-06-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Patrick Heneise |
| Maintainers | eth0lo, hc-eng, patrickheneise |
| Keywords | auth0, integration testing, tests, authentication |

## Links

- npm: https://www.npmjs.com/package/@heneise/auth0-get-token
- Repository: https://github.com/heneise/auth0-get-token
- Homepage: https://github.com/heneise/auth0-get-token#readme
- Issues: https://github.com/heneise/auth0-get-token/issues
- npm.io page: https://npm.io/package/@heneise/auth0-get-token

## Dependencies (1)

- [r2](https://npm.io/package/r2.md) ^2.0.1

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-06-17
- 1.0.0 — 2019-06-14

## README

[![Build Status](https://travis-ci.com/heneise/auth0-get-token.svg?branch=master)](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

![auth0 grant settings](https://user-images.githubusercontent.com/74390/59589705-39a3ce80-90f3-11e9-8a82-f56cbb283eae.png)

- 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')

---
_Source: https://npm.io/package/@heneise/auth0-get-token · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
