简体   繁体   English

如何在我的 web 应用程序中添加 Firebase 应用程序检查 SDK?

[英]How do I add the Firebase app check SDK in my web app?

I have registered my reCAPTCHA v3 secret key in my Firebase console for my web app.我已经在我的 web 应用程序的Firebase console中注册了我的reCAPTCHA v3密钥。 Now I want to add the app check SDK in my client side.现在我想在我的客户端添加应用程序检查 SDK。 These are my imports in my index.html :这些是我在index.html中的导入:

<script src="https://www.gstatic.com/firebasejs/9.14.0/firebase-app-compat.js"></script>

<script src="https://www.gstatic.com/firebasejs/9.14.0/firebase-database-compat.js"></script>

<script src="https://www.gstatic.com/firebasejs/9.14.0/firebase-auth-compat.js"></script>`

<script src="https://www.gstatic.com/firebasejs/9.14.0/firebase-app-check-compat.js" async defer></script>

<script src="https://www.google.com/recaptcha/api.js?render=MY_SITE_KEY_HERE" async defer></script>

This is my javascript :这是我的javascript

const firebaseConfig = {
  apiKey: "ABCDEF",
  authDomain: "ABCDEFGH.firebaseapp.com",
  projectId: "ABCDEFGHO",
  storageBucket: "project_name.appspot.com",
  messagingSenderId: "123456789",
  databaseURL: "https://project)name.firebaseio.com",
  appId: "1:12345678:web:f4r3rsdf322e112c800"
};

firebase.initializeApp(firebaseConfig);

document.getElementById("submit").addEventListener("click",function(event){

     firebase.initializeAppCheck(firebase.initializeApp(firebaseConfig),{
        provider: new ReCaptchaV3Provider('MY_SITE_KEY_HERE'),
        isTokenAutoRefreshEnabled: true
     });
})

Upon clicking the submit button, this error pops up in my console:单击submit按钮后,此错误会在我的控制台中弹出:

Uncaught (in promise) ReferenceError: ReCaptchaV3Provider is not defined未捕获(承诺)ReferenceError:未定义 ReCaptchaV3Provider

How do I fix this?我该如何解决? Is this the correct way to install the app check SDK?这是安装应用程序检查 SDK 的正确方法吗?

you need add import code您需要添加导入代码

import {ReCaptchaV3Provider} from "firebase/app-check"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase:如何在应用检查中注册我的 Flutter 应用? - Firebase: How do I register my Flutter app in app check? 如何在我的 flutter firebase 应用程序中检查用户名可用性 - How can i check username availability in my flutter firebase app 我如何使用 firebase 初始化我的应用程序 - how do i initialize my app using firebase 我是否必须在 Android Studio 和 Firebase 控制台 Z2567A5EC3005EB7AC2CZ948 中将我的应用程序链接到 Firebase? - Do I have to link my app to Firebase in both Android Studio and Firebase Console web? 访问我的 Firebase 托管 web 应用程序(无自定义 URL)后,如何解决“ERR CERT COMMON NAME INVALID”页面? - How do I resolve "ERR CERT COMMON NAME INVALID" page after visiting my Firebase hosting web app (no custom URL)? 我是否需要 Firebase 项目才能使用 Firebase App Check? - Do I need a Firebase project to use Firebase App Check? 使用 firebase SDK 在我的 React 应用程序上进行 Google 分析 - Google analytics on my React app with firebase SDK 无法为我的应用程序(SDK Android 5.0)的通知添加 Firebase FCM。 为什么? - Can't add Firebase FCM for notifications on my app (SDK Android 5.0). Why? 如果我的后端是 firebase firestore,我如何在我的 react js 应用程序中使用 JWT - How do i use JWT in my react js app, if my backend is firebase firestore 如何将用户数据从 firebase 显示到我的 flutter 应用程序? - How do i show user data from firebase to my flutter app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM