From b72e64bcba1bc511b3e76bc9da4f7b8064138f21 Mon Sep 17 00:00:00 2001 From: David Warshaw Date: Sat, 27 Jan 2024 10:22:34 -0500 Subject: [PATCH] Clarify obtaining a refresh token that can be used to obtain JWT access tokens in docs --- EXAMPLES.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/EXAMPLES.md b/EXAMPLES.md index c9c510ed0..dd84d9477 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -54,6 +54,28 @@ const { data: tokens } = await auth.oauth.clientCredentialsGrant({ }); ``` +### Use a Password Grant to get a Refresh Token +```js +import { AuthenticationClient } from 'auth0'; + +const auth = new AuthenticationClient({ + domain: '{YOUR_TENANT_AND REGION}.auth0.com', + clientId: '{YOUR_CLIENT_ID}', + clientSecret: '{YOUR_CLIENT_SECRET}', +}); + +// Get a refresh token +const { + data: { refresh_token }, +} = await auth.oauth.passwordGrant({ + username: '{USER_USERNAME}', + password: '{USER_PASSWORD}', + scope: "offline_access", // To get a refresh token, the scope "offline_access" must be included in the request + audience: 'you-api', // For subsequent refresh token grants to return JWT access tokens, instead of opaque access tokens (tokens without payloads), audience must be included in the original grant +}); + +``` + ### Use Refresh Tokens ```js