Menggunakan App Check dengan penyedia debug dalam C++
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Setelah didaftarkan untuk App Check, aplikasi Anda biasanya tidak akan berjalan
di platform desktop, di emulator, atau dari lingkungan continuous integration (CI)
karena lingkungan tersebut tidak memenuhi syarat sebagai perangkat yang valid. Jika ingin
menjalankan aplikasi di lingkungan tersebut selama pengembangan dan pengujian, Anda
dapat membuat build debug aplikasi yang menggunakan penyedia debug App Check,
bukan penyedia pengesahan asli.
Konfigurasi melalui kode
Untuk menggunakan penyedia debug saat menjalankan aplikasi Anda (misalnya, selama pengembangan), lakukan hal berikut:
Di bagian App Check pada Firebase console, pilih Manage debug tokens dari menu tambahan aplikasi. Kemudian, buat token debug baru. Anda memerlukan token tersebut di langkah berikutnya.
Karena token ini memungkinkan akses ke resource Firebase Anda tanpa perangkat yang valid, Anda harus menjaga kerahasiaannya. Jangan meng-commit token ke repositori publik, dan jika token yang terdaftar pernah terungkap kerahasiaannya, segera cabut token tersebut di Firebase console.
Dalam kode inisialisasi Anda, lakukan hal berikut:
#include"firebase/app_check.h"voidInitializeFirebase(){// Configure the Debug Provider factory with your debug token.firebase::app_check::DebugAppCheckProviderFactory::GetInstance()->SetDebugToken("INSERT YOUR DEBUG TOKEN HERE");// Set App Check to use the debug provider factoryfirebase::app_check::AppCheck::SetAppCheckProviderFactory(firebase::app_check::DebugAppCheckProviderFactory::GetInstance());// Proceed to initialize Firebase as normal}
Opsi konfigurasi lainnya
Opsi konfigurasi lainnya tersedia berdasarkan platform, misalnya menggunakan
variabel lingkungan platform. Untuk mengetahui informasi
selengkapnya, lihat dokumentasi penyedia debug iOS+ atau
Android.
Karena token ini memungkinkan akses ke resource Firebase Anda tanpa
perangkat yang valid, Anda harus menjaga kerahasiaannya. Jangan meng-commit token ke repositori publik, dan jika token yang terdaftar pernah terungkap kerahasiaannya, segera cabut token tersebut di Firebase console.
[null,null,["Terakhir diperbarui pada 2025-08-23 UTC."],[],[],null,["After you have registered your app for App Check, your app normally won't run\non desktop platforms, in an emulator, or from a continuous integration (CI)\nenvironment, since those environments don't qualify as valid devices. If you\nwant to run your app in such an environment during development and testing, you\ncan create a debug build of your app that uses the App Check debug provider\ninstead of a real attestation provider.\n| **Warning:** The debug provider allows access to your Firebase resources from unverified devices. Don't use the debug provider in production builds of your app, and don't share your debug builds with untrusted parties.\n\nConfiguration via code\n\nTo use the debug provider while running your app\n(during development, for example), do the following:\n\n1. In the [**App Check**](//console.firebase.google.com/project/_/appcheck) section\n of the Firebase console, choose **Manage debug tokens** from your app's\n overflow menu. Then, create a new debug token. You'll need the token in the\n next step.\n\n Because this token allows access to your Firebase resources without\n a valid device, it is crucial that you keep it private. Don't commit it to a\n public repository, and if a registered token is ever compromised, revoke it\n immediately in the Firebase console.\n\n2. In your initialization code, do the following:\n\n #include \"firebase/app_check.h\"\n\n void InitializeFirebase() {\n // Configure the Debug Provider factory with your debug token.\n firebase::app_check::DebugAppCheckProviderFactory::GetInstance()\n -\u003eSetDebugToken(\"INSERT YOUR DEBUG TOKEN HERE\");\n\n // Set App Check to use the debug provider factory\n firebase::app_check::AppCheck::SetAppCheckProviderFactory(\n firebase::app_check::DebugAppCheckProviderFactory::GetInstance());\n\n // Proceed to initialize Firebase as normal\n }\n\nOther configuration options\n\nOther configuration options are available based on platform, for example using\nthe platforms environment variables. For more\ninformation, refer to the [iOS+](/docs/app-check/ios/debug-provider) or\n[Android](/docs/app-check/android/debug-provider) debug provider documentation.\n\nBecause this token allows access to your Firebase resources without a\nvalid device, it is crucial that you keep it private. Don't commit it to a\npublic repository, and if a registered token is ever compromised, revoke it\nimmediately in the Firebase console."]]