3

I have the following scenario: a Flutter application backed by a Spring Boot application on AWS. The first time a user tries to log in, they are authenticated by Spring Security with OAuth2 and get a JWT token which is kept in the app's memory for future interactions.

In addition to this first token, there is a secondary Firebase token, signed with a Firebase private key, which is used for all interactions with the Firestore database.

The Firebase connection is well handled, including during loss of Internet connectivity, but whenever a user tries to (first- or re)open the app and Internet connection is unavailable, it hangs during the Firebase sign in.

Is there any way to bypass this? I know they can't authenticate without an Internet connection, but I would like to allow users to access their Firestore local cache while they are offline.

0

1 Answer 1

2

You can enable offline persistence, in web it is disabled by default:

firebase.firestore().enablePersistence()
  .catch(function(err) {
      if (err.code == 'failed-precondition') {
          // Multiple tabs open, persistence can only be enabled
          // in one tab at a a time.
          // ...
      } else if (err.code == 'unimplemented') {
          // The current browser does not support all of the
          // features required to enable persistence
          // ...
      }
  });

You can learn more here

Sign up to request clarification or add additional context in comments.

2 Comments

I realized that offline persistence is enabled by default on Android. I couldn't figure out any way to bypass authentication when offline in the link you shared, @Code Eagle
I think authentication always needs an active connection, anyway your app will still work while offline till restore internet activity and then get the refresh token again, i think all what you can do is to extend the expiration date of refresh token @Jaumzera,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.