Cannot upload to Firebase Storage using Flutter Mobile

663

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');
Share:
663
Xordelish
Author by

Xordelish

Updated on December 02, 2022

Comments

  • Xordelish
    Xordelish over 1 year

    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?

    • Maciej Caputa
      Maciej Caputa over 2 years
      Did you solve the problem?
    • Xordelish
      Xordelish over 2 years
      didn't . my problem wasnt on firebaseappcheck, it was just my internet connection having a different proxy.
  • Xordelish
    Xordelish almost 3 years
    I forgot to mention, my app is not web. And what "site" will I register, if in mobile development?
  • silexcorp
    silexcorp over 2 years
    This is the official documentation, this should solve your doubts, for mobile development: firebase.flutter.dev/docs/app-check/usage