Firebase AppCheck not working
See original GitHub issue[READ] Step 1: Are you in the right place?
Issues filed here should be about bugs in the code in this repository. If you have a general question, need help debugging, or fall into some other category use one of these other channels:
- For general technical questions, post a question on StackOverflow with the firebase tag.
- For general Firebase discussion, use the firebase-talk google group.
- For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.
[REQUIRED] Step 2: Describe your environment
- Android Studio version: 4.1 RC
- Firebase Component: Realtime Database, Appcheck, FirebaseAuth
- Component version: com.google.firebase:firebase-database:20.0.0, com.google.firebase:firebase-appcheck-safetynet:16.0.0-beta02,com.google.firebase:firebase-auth-ktx:21.0.1
[REQUIRED] Step 3: Describe the problem
Steps to reproduce:
After user is authenticated with FirebaseAuth, It cannot load data from real-time database. When I closed the application and reopened it, it worked normally, data were displayed.
Relevant Code:
initialize firebase sdk and appcheck
super.onCreate();
FirebaseApp.initializeApp(this);
FirebaseDatabase.getInstance().setPersistenceEnabled(true);
FirebaseAppCheck firebaseAppCheck = FirebaseAppCheck.getInstance();
firebaseAppCheck.installAppCheckProviderFactory(
SafetyNetAppCheckProviderFactory.getInstance());
firebaseAppCheck.setTokenAutoRefreshEnabled(true);
and I tried to load data by this code
private val collectionEventListener = object : ValueEventListener {
override fun onCancelled(error: DatabaseError) {
Log.e("data","error")
}
override fun onDataChange(snapshot: DataSnapshot) {
Log.d("data","loaded")
}
}
FirebaseAuth.getInstance().addIdTokenListener(FirebaseAuth.IdTokenListener {
val user = it.currentUser
if(user!=null){
FirebaseDatabase.getInstance().reference.child("tasks").child(user.uid).addValueEventListener(object:
ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
Log.e("data","onDataChange")
}
override fun onCancelled(error: DatabaseError) {
Log.e("data","onCancelled")
}
})
}
})
It didn’t even run into the onDataChange or onCancelled callback and didn’t log anything.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Using Firebase App Check is not working (debug)
Run the App on Physical device. I was facing the same issue and but when i run the app on a physical device...
Read more >Firebase App Check - Google
App Check helps protect your app from abuse by attesting that incoming traffic is coming from your app and blocking traffic without valid...
Read more >[App Check] Firebase App Check token is invalid. · Issue #6957
The problem happens trying to upload a file to Firebase Storage: W/StorageUtil: Error getting App Check token; using placeholder token ...
Read more >How to Secure your Firebase Backend Access with App ...
Just use the SafetyNet provider if you encounter any issues. First, open the App Check menu in your Firebase Console. Screenshot of Firebase...
Read more >Use App Check with the debug provider - FlutterFire
need to safelist it in the Firebase console for it to work. Copy. Activating the debug provider (Android)#. Add the dependency for App...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@linhttbk thanks for reporting. I can’t reproduce the issue using quickstart. Just to make sure we’re on the same page, I’d like to request a minimal, reproducible example of your project and the complete steps you’ve taken before facing this issue with complete error logs. Thanks.
Since there haven’t been any recent updates here, I am going to close this issue.
@linhttbk if you’re still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.