B4J Question Firebase Server

Randori

Member
Licensed User
Longtime User
I have configured per the example in this thread: B4J Library [server] FirebaseServer - backend verification for signed in users

I am getting this error:

java.lang.IllegalArgumentException
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:111)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
at com.google.api.client.json.webtoken.JsonWebSignature$Parser.parse(JsonWebSignature.java:599)
at com.google.firebase.auth.FirebaseToken.parse(FirebaseToken.java:81)
at com.google.firebase.auth.FirebaseAuth$1.call(FirebaseAuth.java:143)
at com.google.firebase.auth.FirebaseAuth$1.call(FirebaseAuth.java:140)
at com.google.firebase.tasks.Tasks$1.run(Tasks.java:63)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)


Any assistance would be appreciated.
 

Randori

Member
Licensed User
Longtime User
Yes, I completed the instructions up to the point of downloading the JSON file and placed that file into the files tab of the B4J project.

I stopped at this point in the instructions: When you create the service account, a JSON file containing your service account's credentials is downloaded for you. You'll need this to initialize the SDK in the next step.

Correct me if I am wrong, but the initialization of the SDK takes place in B4J with this command:
fs.Initialize("fs", File.OpenInput(File.DirAssets, "RepairShop-XXXXXXXXXXXX.json"))

Here is my MAIN code...It is a combination of jRDC and Firebase Server and the jRDC portion works just fine...I have omitted the token and json names:


B4X:
'Non-UI application (console / server application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

#AdditionalJar: jtds-1.3.1.jar
#AdditionalJar: firebase-server-sdk.jar


Sub Process_Globals
    Public srvr As Server
    Public rdcConnector1 As RDCConnector
    Public const VERSION As Float = 2.1
    Type DBCommand (Name As String, Parameters() As Object)
    Type DBResult (Tag As Object, Columns As Map, Rows As List)
   
    Private fs As FirebaseServer
End Sub

Sub AppStart (Args() As String)
   
  
   
    srvr.Initialize("")
    rdcConnector1.Initialize
    srvr.Port = rdcConnector1.serverPort
    srvr.AddHandler("/test", "TestHandler", False)
    srvr.AddHandler("/rdc", "RDCHandler", False)
    srvr.Start
    Log($"jRDC is running (version = $1.2{VERSION})"$)
   
   
    fs.Initialize("fs", File.OpenInput(File.DirAssets, "RepairShop-XXXXXXXXXXX.json"))
    fs.VerifyToken("XXXXXXXXXXXXXXX")
   
    StartMessageLoop
   
   
End Sub

Sub fs_TokenVerified (TokenId As String, Success As Boolean, Token As FirebaseToken)
   If Success Then
     Log(Token.DisplayName)
     Log(Token.Email)
     Log(Token.Uid)
    Else
        Log("Sorry no good!")
   End If
End Sub
 
Upvote 0
Top