question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useAppCheck and/or preloadAppCheck

See original GitHub issue

Hi, I think it would be a good idea to add useAppCheck and/or preloadAppCheck to provide functionality form https://firebase.google.com/docs/app-check

Version info

React: ^17.0.2

Firebase: ^8.7.1

ReactFire: ^3.0.0-rc.2

Steps to reproduce

  1. Add import 'firebase/app-check';
  2. Add useFirebaseApp().appCheck().activate('YOUR KEY')

Expected behavior

I have an app check working.

Actual behavior

Uncaught FirebaseError: AppCheck: You are trying to activate AppCheck for FirebaseApp [DEFAULT], while it is already activated. AppCheck can only be activated once. (appCheck/already-activated).

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
epodolcommented, Jul 22, 2021

A provider for App Check would probably be ideal. In my opinion, an activateCallback would be better because it would allow for more customization for individual use cases, and reduce any breaking api changes in the future if firebase changes the activate arguments.

1reaction
jhuleattcommented, Jul 22, 2021

Thanks @MaciejCaputa for the feature request, and thank you @epodol for your temporary solution!

This is definitely an important feature to add to ReactFire. Let’s discuss a potential API. I wonder if we should have another Provider for AppCheck. It seems important to be able to be confident that AppCheck is activated before any calls are made that could be denied by AppCheck.

For example, it could look like:

<FirebaseAppProvider firebaseConfig={/* config... */}>
    <AppCheckProvider publicKey={/* recaptcha public key... */}>
        <MyChatApp />
    </AppCheckProvider>
</FirebaseAppProvider>

Then, I could be confident that any Realtime Database, Cloud Storage, or Cloud Functions (callable functions) calls that I make within <MyChatApp /> are made after AppCheck is activated.

This could also be done in FirebaseAppProvider, but separating it out may be good to reduce bundle size for those that aren’t using AppCheck.

The props for AppCheckProvider would likely have to account for all of the arguments activate accepts: siteKeyOrProvider : string | AppCheckProvider , isTokenAutoRefreshEnabled ? : boolean


How does this sound to you? How can we make it better?

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found