Skip to content

Commit 74b104c

Browse files
Show isTokenAutoRefreshEnabled in App Check (#208)
* Show isTokenAutoRefreshEnabled in App Check * npm run snippets
1 parent da7abdb commit 74b104c

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

appcheck-next/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ function initialize() {
1313
// Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this
1414
// key is the counterpart to the secret key you set in the Firebase console.
1515
const appCheck = initializeAppCheck(app, {
16-
provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd')
16+
provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd'),
17+
18+
// Optional argument. If true, the SDK automatically refreshes App Check
19+
// tokens as needed.
20+
isTokenAutoRefreshEnabled: true
1721
});
1822
// [END appcheck_initialize]
1923
}
@@ -59,7 +63,11 @@ function initializeCustomProvider() {
5963
});
6064

6165
const appCheck = initializeAppCheck(app, {
62-
provider: appCheckCustomProvider
66+
provider: appCheckCustomProvider,
67+
68+
// Optional argument. If true, the SDK automatically refreshes App Check
69+
// tokens as needed.
70+
isTokenAutoRefreshEnabled: true
6371
});
6472
// [END appcheck_initialize_custom_provider]
6573
}

appcheck/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ function initialize() {
1010
const appCheck = firebase.appCheck();
1111
// Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this
1212
// key is the counterpart to the secret key you set in the Firebase console.
13-
appCheck.activate('abcdefghijklmnopqrstuvwxy-1234567890abcd');
13+
appCheck.activate(
14+
'abcdefghijklmnopqrstuvwxy-1234567890abcd',
15+
16+
// Optional argument. If true, the SDK automatically refreshes App Check
17+
// tokens as needed.
18+
true);
1419
// [END appcheck_initialize]
1520
}
1621

@@ -50,7 +55,12 @@ function initializeCustomProvider() {
5055
});
5156

5257
const appCheck = firebase.appCheck();
53-
appCheck.activate(appCheckCustomProvider);
58+
appCheck.activate(
59+
appCheckCustomProvider,
60+
61+
// Optional argument. If true, the SDK automatically refreshes App Check
62+
// tokens as needed.
63+
true);
5464
// [END appcheck_initialize_custom_provider]
5565
}
5666

snippets/appcheck-next/index/appcheck_initialize.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ const app = initializeApp({
1414
// Pass your reCAPTCHA v3 site key (public key) to activate(). Make sure this
1515
// key is the counterpart to the secret key you set in the Firebase console.
1616
const appCheck = initializeAppCheck(app, {
17-
provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd')
17+
provider: new ReCaptchaV3Provider('abcdefghijklmnopqrstuvwxy-1234567890abcd'),
18+
19+
// Optional argument. If true, the SDK automatically refreshes App Check
20+
// tokens as needed.
21+
isTokenAutoRefreshEnabled: true
1822
});
1923
// [END appcheck_initialize_modular]

snippets/appcheck-next/index/appcheck_initialize_custom_provider.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const app = initializeApp({
1212
});
1313

1414
const appCheck = initializeAppCheck(app, {
15-
provider: appCheckCustomProvider
15+
provider: appCheckCustomProvider,
16+
17+
// Optional argument. If true, the SDK automatically refreshes App Check
18+
// tokens as needed.
19+
isTokenAutoRefreshEnabled: true
1620
});
1721
// [END appcheck_initialize_custom_provider_modular]

0 commit comments

Comments
 (0)