Skip to content

Commit 73603b6

Browse files
Merge branch 'main' into dependabot/github_actions/snyk/actions-1.0.0
2 parents fb8b69c + dd8982a commit 73603b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+667
-217
lines changed

.github/workflows/browserstack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
ref: ${{ github.event.pull_request.head.sha || github.ref }}
3636

3737
- name: Setup Node
38-
uses: actions/setup-node@v5
38+
uses: actions/setup-node@v6
3939
with:
4040
node-version: ${{ env.NODE_VERSION }}
4141
cache: npm

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ jobs:
4040
uses: actions/checkout@v5
4141

4242
- name: Initialize CodeQL
43-
uses: github/codeql-action/init@v3
43+
uses: github/codeql-action/init@v4
4444
with:
4545
languages: ${{ matrix.language }}
4646
queries: +security-and-quality
4747

4848
- name: Autobuild
49-
uses: github/codeql-action/autobuild@v3
49+
uses: github/codeql-action/autobuild@v4
5050

5151
- name: Perform CodeQL Analysis
52-
uses: github/codeql-action/analyze@v3
52+
uses: github/codeql-action/analyze@v4
5353
with:
5454
category: '/language:${{ matrix.language }}'

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
uses: actions/checkout@v5
4949

5050
- name: Setup Node
51-
uses: actions/setup-node@v5
51+
uses: actions/setup-node@v6
5252
with:
5353
node-version: ${{ env.NODE_VERSION }}
5454
cache: npm
@@ -60,4 +60,6 @@ jobs:
6060
run: npm run test
6161

6262
- name: Upload coverage
63-
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # [email protected]
63+
uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # [email protected]
64+
with:
65+
token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,4 @@ test-results
108108

109109
cypress/screenshots
110110
cypress/videos
111+
.npmrc

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2.5.0
1+
v2.8.0

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change Log
22

3+
## [v2.8.0](https://github.com/auth0/auth0-react/tree/v2.8.0) (2025-10-17)
4+
[Full Changelog](https://github.com/auth0/auth0-react/compare/v2.7.0...v2.8.0)
5+
6+
**Added**
7+
- Bump auth0-spa-js for connected account updates [\#923](https://github.com/auth0/auth0-react/pull/923) ([adamjmcgrath](https://github.com/adamjmcgrath))
8+
9+
## [v2.7.0](https://github.com/auth0/auth0-react/tree/v2.7.0) (2025-10-15)
10+
[Full Changelog](https://github.com/auth0/auth0-react/compare/v2.6.0...v2.7.0)
11+
12+
**Added**
13+
- Add support for connected accounts [\#912](https://github.com/auth0/auth0-react/pull/912) ([adamjmcgrath](https://github.com/adamjmcgrath))
14+
15+
## [v2.6.0](https://github.com/auth0/auth0-react/tree/v2.6.0) (2025-10-06)
16+
[Full Changelog](https://github.com/auth0/auth0-react/compare/v2.5.0...v2.6.0)
17+
18+
**Added**
19+
- Implement MRRT [\#906](https://github.com/auth0/auth0-react/pull/906) ([aridibag](https://github.com/aridibag))
20+
321
## [v2.5.0](https://github.com/auth0/auth0-react/tree/v2.5.0) (2025-09-17)
422
[Full Changelog](https://github.com/auth0/auth0-react/compare/v2.4.0...v2.5.0)
523

EXAMPLES.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
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](#using-multi-resource-refresh-tokens)
13+
- [Connect Accounts for using Token Vault](#connect-accounts-for-using-token-vault)
1214

1315
## Use with a Class Component
1416

@@ -571,3 +573,113 @@ createFetcher({
571573
})
572574
});
573575
```
576+
577+
## Using Multi-Resource Refresh Tokens
578+
579+
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.
580+
581+
- [Multi-Resource Refresh Token](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token)
582+
583+
## Enabling MRRT
584+
585+
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:
586+
587+
```jsx
588+
<Auth0Provider
589+
domain="YOUR_AUTH0_DOMAIN"
590+
clientId="YOUR_AUTH0_CLIENT_ID"
591+
useRefreshTokens={true}
592+
useRefreshTokensFallback={true}
593+
useMrrt={true} // 👈
594+
authorizationParams={{ redirect_uri: window.location.origin }}
595+
>
596+
```
597+
598+
> [!IMPORTANT]
599+
> In order MRRT to work, it needs a previous configuration setting the refresh token policies.
600+
> Visit [configure and implement MRRT.](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token/configure-and-implement-multi-resource-refresh-token)
601+
602+
## Connect Accounts for using Token Vault
603+
604+
The Connect Accounts feature uses the Auth0 My Account API to allow users to link multiple third party accounts to a single Auth0 user profile.
605+
606+
When using Connected Accounts, Auth0 acquires tokens from upstream Identity Providers (like Google) and stores them in a secure [Token Vault](https://auth0.com/docs/secure/tokens/token-vault). These tokens can then be used to access third-party APIs (like Google Calendar) on behalf of the user.
607+
608+
The tokens in the Token Vault are then accessible to [Resource Servers](https://auth0.com/docs/get-started/apis) (APIs) configured in Auth0. The SPA application can then issue requests to the API, which can retrieve the tokens from the Token Vault and use them to access the third-party APIs.
609+
610+
This is particularly useful for applications that require access to different resources on behalf of a user, like AI Agents.
611+
612+
### Configure the SDK
613+
614+
The SDK must be configured with an audience (an API Identifier) - this will be the resource server that uses the tokens from the Token Vault.
615+
616+
The SDK must also be configured to use refresh tokens and MRRT ([Multiple Resource Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens/multi-resource-refresh-token)) since we will use the refresh token grant to get Access Tokens for the My Account API in addition to the API we are calling.
617+
618+
The My Account API requires DPoP tokens, so we also need to enable DPoP.
619+
620+
```jsx
621+
<Auth0Provider
622+
domain="YOUR_AUTH0_DOMAIN"
623+
clientId="YOUR_AUTH0_CLIENT_ID"
624+
authorizationParams={{
625+
redirect_uri: window.location.origin,
626+
audience: '<AUTH0 API IDENTIFIER>' // The API that will use the tokens from the Token Vault
627+
}}
628+
useRefreshTokens={true}
629+
useMrrt={true}
630+
useDpop={true}
631+
>
632+
<App />
633+
</Auth0Provider>
634+
```
635+
636+
### Login to the application
637+
638+
Use the login methods to authenticate to the application and get a refresh and access token for the API.
639+
640+
```jsx
641+
const Login = () => {
642+
const { loginWithRedirect } = useAuth0();
643+
return <button onClick={() => loginWithRedirect({
644+
authorizationParams: {
645+
audience: '<AUTH0 API IDENTIFIER>', // The API that will use the tokens from the Token Vault
646+
scope: 'openid profile email offline_access read:calendar' // Make sure you get a Refresh Token as you're using MRRT to get access to the My Account API
647+
}
648+
})}>Login</button>;
649+
};
650+
```
651+
652+
### Connect to a third party account
653+
654+
Use the new `connectAccountWithRedirect` method to redirect the user to the third party Identity Provider to connect their account.
655+
656+
```jsx
657+
const ConnectAccount = () => {
658+
const { connectAccountWithRedirect } = useAuth0();
659+
return <button onClick={() => connectAccountWithRedirect({
660+
connection: '<CONNECTION eg, google-apps-connection>',
661+
access_type: 'offline', // You must also request a refresh token from the third party Identity Provider for it to be stored in Token Vault.
662+
authorization_params: {
663+
scope: '<SCOPE eg https://www.googleapis.com/auth/calendar.acls.readonly>'
664+
}
665+
})}>Connect Google Calendar</button>;
666+
};
667+
```
668+
669+
When the redirect completes, the user will be returned to the application and the tokens from the third party Identity Provider will be stored in the Token Vault.
670+
671+
```jsx
672+
<Auth0Provider
673+
// ...
674+
onRedirectCallback={(appState) => {
675+
if (appState.connectedAccount) {
676+
console.log(`You've connected to ${appState.connectedAccount.connection}`);
677+
}
678+
window.history.replaceState({}, document.title, '/');
679+
}}
680+
>
681+
<App />
682+
</Auth0Provider>
683+
```
684+
685+
You can now [call the API](#calling-an-api) with your access token and the API can use [Access Token Exchange with Token Vault](https://auth0.com/docs/secure/tokens/token-vault/access-token-exchange-with-token-vault) to get tokens from the Token Vault to access third party APIs on behalf of the user.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![npm](https://img.shields.io/npm/v/@auth0/auth0-react.svg?style=flat)](https://www.npmjs.com/package/@auth0/auth0-react)
44
[![codecov](https://img.shields.io/codecov/c/github/auth0/auth0-react/main.svg?style=flat)](https://codecov.io/gh/auth0/auth0-react)
5+
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/auth0/auth0-react)
56
![Downloads](https://img.shields.io/npm/dw/@auth0/auth0-react)
67
[![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
78
[![CircleCI](https://img.shields.io/circleci/build/github/auth0/auth0-react.svg?branch=main&style=flat)](https://circleci.com/gh/auth0/auth0-react)
@@ -181,4 +182,4 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
181182
</p>
182183
<p align="center">Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a></p>
183184
<p align="center">
184-
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-react/blob/main/LICENSE"> LICENSE</a> file for more info.</p>
185+
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/auth0-react/blob/main/LICENSE"> LICENSE</a> file for more info.</p>

__mocks__/@auth0/auth0-spa-js.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const actual = jest.requireActual('@auth0/auth0-spa-js');
2+
13
const handleRedirectCallback = jest.fn(() => ({ appState: {} }));
24
const buildLogoutUrl = jest.fn();
35
const buildAuthorizeUrl = jest.fn();
@@ -9,6 +11,7 @@ const getIdTokenClaims = jest.fn();
911
const isAuthenticated = jest.fn(() => false);
1012
const loginWithPopup = jest.fn();
1113
const loginWithRedirect = jest.fn();
14+
const connectAccountWithRedirect = jest.fn();
1215
const logout = jest.fn();
1316
const getDpopNonce = jest.fn();
1417
const setDpopNonce = jest.fn();
@@ -28,10 +31,13 @@ export const Auth0Client = jest.fn(() => {
2831
isAuthenticated,
2932
loginWithPopup,
3033
loginWithRedirect,
34+
connectAccountWithRedirect,
3135
logout,
3236
getDpopNonce,
3337
setDpopNonce,
3438
generateDpopProof,
3539
createFetcher,
3640
};
3741
});
42+
43+
export const ResponseType = actual.ResponseType;

0 commit comments

Comments
 (0)