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.

FirebaseAppCheck.getAppCheckToken(true) does not appear to force refresh all the time?

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: 7.0.2
  • Firebase Component: AppCheck
  • Component version: from BoM 28.4.0

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

If you call these two methods back to back the tokens are equal in certain cases. Is that expected? Shouldn’t force refreshing the token always get a new token? 🤔

pseudo-code:

token1 = FirebaseAppCheck.getAppCheckToken();`
token2 = FirebaseAppCheck.getAppCheckToken(true);

// sometimes token1 == token2?
// But then if you wait 5 seconds and re-try both back to back you will get token1 != token2 

Relevant Code:

We test this case here, you can run it

https://github.com/invertase/react-native-firebase/blob/90b4d7021aff7d5d28140b57eb69283b04712257/packages/app-check/e2e/appcheck.e2e.js#L54-L65

The (boring, by the book) Java code it exercises is:

https://github.com/invertase/react-native-firebase/blob/90b4d7021aff7d5d28140b57eb69283b04712257/packages/app-check/android/src/main/java/io/invertase/firebase/appcheck/ReactNativeFirebaseAppCheckModule.java#L73-L95

This same test found an actual crash in the firebase-ios-sdk which was just resolved https://github.com/firebase/firebase-ios-sdk/issues/8544 - so perhaps this is just an unexpected (though still valid) use case?

Or perhaps my expectations of the API are incorrect?

Any insight appreciated - thanks!

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
aguatnocommented, Sep 6, 2021

Hi @mikehardy thanks for reporting. Based on the documentation it says there that it should give you a Firebase App Check token. Let me check with the team if this is expected or a possible bug.

0reactions
mikehardycommented, Sep 14, 2021

Hmm - I just re-read that line in our module to see if there was some action we could/should take and given the API call into the firebase-android-sdk is a single line I don’t think we can do anything to impact order of operations and guarantee fresh token? I ask that for confirmation, since obviously if our code is buggy I’d love to know so I can focus personal effort and fix it 😃. Only other thing I can think of is to perhaps test for a true parameter to the function and then do a sort of retry loop until the token really was refreshed but that would be a workaround for a still-in-error underlying issue, if I’m understanding correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is difference between the getIdToken and ...
Fetches a Firebase Auth ID Token for the user; useful when authenticating against your own backend, if forceRefresh == true, thrown if the ......
Read more >
FirebaseAppCheck - Google
Automatic token refreshing will only occur if the global isDataCollectionDefaultEnabled flag is set to true. To allow automatic token refreshing for ...
Read more >
Secure your Next.js application with Firebase AppCheck
The service is free and helps us protect Firebase Authentication, Firebase Storage, Firebase Firestore and any custom API against threats and ...
Read more >
Protecting your backends with Firebase App Check
Not only can App Check protect hosted APIs (such as Cloud Storage for ... should ensure that all requests originate from your app—and...
Read more >
How to Fix Instagram Couldn't Refresh Feed - Alphr
The inability to view the latest posts and stories can appear ... If Instagram's time and date don't match the ones you've selected,...
Read more >

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