Android Question Firebase TokenId TimedOut

lip

Active Member
Licensed User
Longtime User
Firebase Auth:
Sub Auth_TokenAvailable (User As FirebaseUser, Success As Boolean, TokenId As String)

This fires when the App is launched and the Google user is logged in. I get the TokenId and store it as a string in Process_Globals in the Starter service. I include the JWT as a parameter in all Posts to my server.

I use the Firebase SDK to validate the JWT in the server, which includes a check that the validity date/times in the claims are current, which initially they are, but after a couple of hours they have timed-out.

Should I periodically (or just before using) check the dates in my stored TokenId in my B4A app and if they are old, refresh the TokenId? I don't really want to get a new TokenId every time I call the API.

Also - how do I get the claims from the TokenId from within the B4A App (so that I can check the valid times and get a new Token if necessary)? I guess that there is a JWT parser in a B4A library somewhere but I've not found it.

Thanks in advance to anyone who can help
 
Last edited:

lip

Active Member
Licensed User
Longtime User
jFirebaseServer
Logs on Compile:
Compiling resources    (0.10s)
Linking resources    (0.80s)
Compiling generated Java code.    (0.07s)
Convert byte code - optimized dex.    Error
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseApp;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseApp$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseAppLifecycleListener;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseException;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseOptions;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseOptions$1;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/FirebaseOptions$Builder;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/auth/FirebaseAuth;
Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/firebase/auth/FirebaseAuthException;
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.RuntimeException: Translation has been interrupted
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:692)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:315)
    at com.android.dx.command.dexer.Main.runDx(Main.java:293)
    at com.android.dx.command.dexer.Main.main(Main.java:249)
    at com.android.dx.command.Main.main(Main.java:94)
Caused by: java.lang.InterruptedException: Too many errors
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:684)
    ... 4 more
 
Upvote 0

lip

Active Member
Licensed User
Longtime User
Not sure if I've put this in the right place:

Starter: Service_Create
Initiliasing jFirebaseServer with the Service JSON in Files tab:
Dim FirebaseJSON As InputStream = File.OpenInput(File.DirAssets,"xxxx-firebase-adminsdk-xxxxa.json")
    jFirebaseServer.Initialize("FirebaseServer",FirebaseJSON)
 
Upvote 0
Top