Cannot upload to Firebase Storage using Flutter Mobile

Viewed 861

I'm new to Flutter and I'm stuck trying to upload an image from a Flutter App to Firebase Storage. It always throws the same exception:

W/ExponenentialBackoff( 1185): network unavailable, sleeping.
W/StorageUtil( 1185): Error getting App Check token; using placeholder token instead. Error: com.google.firebase.FirebaseException: 16:

I have already connected my Firebase Console to my Flutter App. My Firestore is working, except for Cloud Storage. I believe it's because of the App Check that needs to be configured using a recaptcha key to be run in "main.dart" below Firebase.initializeApp(), as FlutterFire specifically instructs: https://firebase.flutter.dev/docs/app-check/usage#activating-the-default-provider

  await FirebaseAppCheck.instance.activate(webRecaptchaSiteKey: 'recaptcha-v3-site-key');
  

Thing is, I don't know where to find that recaptcha key from my Firebase Console or how to set it up. I've tried plugging in the WEB API KEY in my Firebase Project but it still doesn't work. Can anyone help?

1 Answers

Here are the steps to get the webRecaptchaSiteKey according to the documentation:

  1. Add Firebase to your JavaScript project if you haven’t already done so.

  2. Register your site for reCAPTCHA v3 and get your reCAPTCHA v3 site key and secret key.

  3. Register your apps to use App Check with the reCAPTCHA provider in the Project Settings > App Check section of the Firebase console. You will need to provide the secret key you got in the previous step.

After following these steps, you can pass the site key (public key), say 'abcdefghijklmnopqrstuvwxy-1234567890abcd', from step 2 and use it like below:

  await FirebaseAppCheck.instance.activate(webRecaptchaSiteKey: 'abcdefghijklmnopqrstuvwxy-1234567890abcd');
Related