Use App Check with the debug provider
Notice
This page is archived and might not reflect the latest version of the FlutterFire plugins. You can find the latest information on firebase.google.com:
https://firebase.google.com/docs/app-check/flutter/debug-provider
If, after you have registered your app for App Check, and you want to run your app in an environment that App Check would normally not classify as valid, such as a simulator during development, or from a continuous integration (CI) environment, you can create a debug build of your app that uses the App Check debug provider instead of a real attestation provider.
caution
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.
For now the debug provider does not currently have a Dart API; you'll need to apply the changes for your platforms as shown below:
#
Activating the debug provider (iOS/macOS)Add the dependency for App Check to your project's Podfile
Set the debug provider in your App Delegate:
- Objective-C
- Swift
Launch your application. A local debug token will be logged when the SDK tries to send a request to the backend. For example:
#
Activating the debug provider (Web)Set the global FIREBASE_APPCHECK_DEBUG_TOKEN
flag to true before your Firebase JS SDKs in your index.html
:
Visit your web app locally and open the browser’s developer tool. In the debug console, you’ll see a debug token:
#
Activating the debug provider (Android)Add the dependency for App Check to your project's android/app/build.gradle
:
Install the debug provider using the following snippet, e.g. in your MainActivity.java onCreate method:
Launch the app and trigger a call to a Firebase backend service. A local debug token will be logged when the SDK tries to send a request to the backend. For example:
#
Add a debug token to Firebase Project settingsIn the Project Settings > App Check section of the Firebase console, choose Manage debug tokens from your app's overflow menu. Then, register the debug token you logged in the previous step.
After you register the token, Firebase backend services will accept it as valid.
Because this token allows access to your Firebase resources without a valid device, it is crucial that you keep it private. Don't commit it to a public repository, and if a registered token is ever compromised, revoke it immediately in the Firebase console.
#
App Check for FunctionsEnsure you have App Check for Functions enabled, and check the context for the App Check token:
You may also use the Firebase Local Emulator Suite to test your Cloud Function. You simply have to add another conditional check (i.e. !process.env.FUNCTIONS_EMULATOR
) to stop errors from throwing whilst testing: