Skip to content

Commit 72a0c44

Browse files
authored
Implement MRRT (#906)
By submitting a PR to this repository, you agree to the terms within the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md). Please see the [contributing guidelines](https://github.com/auth0/.github/blob/master/CONTRIBUTING.md) for how to create and submit a high-quality PR for this repo. ### Description In this PR, `auth0-spa-js` has been updated to allow `auth0-react` to use [Multi-Resource Refresh Tokens (MRRT)](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token). An example of configuring the Auth0Provider to use MRRT has also been provided. ### Testing - [Configure MRRT](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token/configure-and-implement-multi-resource-refresh-token). - In your react testing application, add `useMrrt`, `useRefreshTokens` and `useRefreshTokensFallback` to `true`, following the example on `EXAMPLE.MD`. - Get a token for audience 1. - Try to get a token for audience 2 using the refresh token from audience 1. - [x] This change adds test coverage for new/changed/fixed functionality ### Checklist - [x] I have added documentation for new/changed functionality in this PR or in auth0.com/docs - [x] All active GitHub checks for tests, formatting, and security are passing - [x] The correct base branch is being used, if not the default branch
1 parent 230ec34 commit 72a0c44

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

EXAMPLES.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Use with Auth0 organizations](#use-with-auth0-organizations)
1010
- [Protecting a route with a claims check](#protecting-a-route-with-a-claims-check)
1111
- [Device-bound tokens with DPoP](#device-bound-tokens-with-dpop)
12+
- [Using Multi Resource Refresh Tokens]()
1213

1314
## Use with a Class Component
1415

@@ -571,3 +572,28 @@ createFetcher({
571572
})
572573
});
573574
```
575+
576+
## Using Multi-Resource Refresh Tokens
577+
578+
With **Multi-Resource Refresh Tokens** -or simply **MRRT**- now a refresh token from one API, can be used to request a new access token from another different API. Read more about how MRRT works for browser-based applications to help you decide, wether you need or not, to use this functionality.
579+
580+
- [Multi-Resource Refresh Token](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token)
581+
582+
## Enabling MRRT
583+
584+
MRRT is disabled by default. To enable it, set the `useMrrt` option to `true` when invoking the provider. You will need to set `useRefreshTokens` and `useRefreshTokensFallback` to `true` as well For example:
585+
586+
```jsx
587+
<Auth0Provider
588+
domain="YOUR_AUTH0_DOMAIN"
589+
clientId="YOUR_AUTH0_CLIENT_ID"
590+
useRefreshTokens={true}
591+
useRefreshTokensFallback={true}
592+
useMrrt={true} // 👈
593+
authorizationParams={{ redirect_uri: window.location.origin }}
594+
>
595+
```
596+
597+
> [!IMPORTANT]
598+
> In order MRRT to work, it needs a previous configuration setting the refresh token policies.
599+
> Visit [configure and implement MRRT.](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token/configure-and-implement-multi-resource-refresh-token)

package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@
9595
"react-dom": "^16.11.0 || ^17 || ^18 || ^19"
9696
},
9797
"dependencies": {
98-
"@auth0/auth0-spa-js": "^2.4.1"
98+
"@auth0/auth0-spa-js": "^2.5.0"
9999
}
100100
}

0 commit comments

Comments
 (0)