I tried to follow the following example for Google authentication
but I get the same error that I have seen in the forum in some posts without any answer.
I guess my real question is where did I get the VerifyToken("eyJhbGciOiJSUzI1NiIsImtpZCI6IjE1ZWE4ZDBkMDI1ZDExNGFiNzU0MmQ2OT...")
I thought I could create it by sending the google email and password parameters but I can't find any function that allows me to do it.
I am not very good with this I always rely on the guides I do not know if this library is still functional.
i all ready have de json file from the image
this is my main code:
thanks for your help
[server] FirebaseServer - backend verification for signed in users
Users can sign in to your B4A or B4i apps using Google or Facebook with the FirebaseAuth libraries. FirebaseServer completes the puzzle with server side verification of the user. This means that the signed in user gets a token id (long string) from Firebase services by calling...www.b4x.com
but I get the same error that I have seen in the forum in some posts without any answer.
error:
Waiting for debugger to connect...
Program started.
2023-08-09 18:25:05.354:INFO :cmvl.MLog:MLog-Init-Reporter: MLog clients using slf4j logging.
2023-08-09 18:25:06.022:INFO :cmvc.C3P0Registry:main: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
2023-08-09 18:25:06.497:INFO :oejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 11.0.1+13
2023-08-09 18:25:06.684:INFO :oejss.DefaultSessionIdManager:main: Session workerName=node0
2023-08-09 18:25:06.707:INFO :oejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@3a5ecce3{/,file:///C:/Users/MacBookPro/Desktop/Sistema%20Prestamos%20Cloud/Prestamos%20Cloud/Objects/www/,AVAILABLE}
2023-08-09 18:25:06.760:INFO :oejs.RequestLogWriter:main: Opened C:\Users\MacBookPro\Desktop\Sistema Prestamos Cloud\Prestamos Cloud\Objects\logs\b4j-2023_08_10.request.log
2023-08-09 18:25:06.781:INFO :oejs.AbstractConnector:main: Started ServerConnector@782859e{HTTP/1.1, (http/1.1)}{0.0.0.0:51042}
2023-08-09 18:25:06.828:INFO :oejus.SslContextFactory:main: x509=X509@30b19518(1,h=[localhost],a=[/127.0.0.1],w=[]) for Server@62e20a76[provider=null,keyStore=file:///C:/Users/MacBookPro/Desktop/Sistema%20Prestamos%20Cloud/Prestamos%20Cloud/Objects/localhost.jks,trustStore=null]
2023-08-09 18:25:07.007:INFO :oejs.AbstractConnector:main: Started ServerConnector@69ee81fc{SSL, (ssl, http/1.1)}{0.0.0.0:51044}
2023-08-09 18:25:07.012:INFO :oejs.Server:main: Started Server@1f81aa00{STARTING}[11.0.9,sto=0] @3410ms
Emulated network latency: 100ms
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.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Token verification failed
I guess my real question is where did I get the VerifyToken("eyJhbGciOiJSUzI1NiIsImtpZCI6IjE1ZWE4ZDBkMDI1ZDExNGFiNzU0MmQ2OT...")
I thought I could create it by sending the google email and password parameters but I can't find any function that allows me to do it.
I am not very good with this I always rely on the guides I do not know if this library is still functional.
i all ready have de json file from the image
this is my main code:
main code:
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#AdditionalJar: mysql-connector-j-8.1.0.jar
#End Region
Sub Process_Globals
Public srvr As Server
Public pool As ConnectionPool
Private fs As FirebaseServer
End Sub
Sub AppStart (Args() As String)
pool.Initialize("com.mysql.jdbc.Driver","jdbc:mysql://127.0.0.1/sistemacloud?Encoding=utf8","user","pass")
srvr.Initialize("srvr")
srvr.Port = 51042
srvr.StaticFilesFolder = File.Combine(File.DirApp, "www")
srvr.AddWebSocket("/login", "login")
srvr.AddWebSocket("/Dashboard", "Dashboard")
srvr.AddFilter("/b4j_ws.js", "SessionCreator", False)
ConfigureSSL(51044)
srvr.Start
fs.Initialize("fs", File.OpenInput(File.DirAssets, "sistema-prestamos-cloud-firebase-adminsdk-j5vcp-6e3a8c3bed.json"))
'fs.VerifyToken("AIzaSyBElE2gscykbUfTYKwQ7Omt5q-2cF18odc")
StartMessageLoop
'open browser and navigate to: http://127.0.0.1:51042/
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)
' End If
'End Sub
Sub verifytoken(token As String)
fs.VerifyToken(token)
End Sub
Sub fs_TokenVerified (TokenId As String, Success As Boolean, Token As FirebaseToken)
If Success Then
Log("User verified:")
Log("Display Name: " & Token.DisplayName)
Log("Email: " & Token.Email)
Log("User ID: " & Token.Uid)
Else
Log("Token verification failed")
End If
End Sub
Private Sub ConfigureSSL (SslPort As Int)
'example of SSL connector configuration
Dim ssl As SslConfiguration
ssl.Initialize
ssl.SetKeyStorePath(File.DirApp, "localhost.jks") 'path to keystore file
ssl.KeyStorePassword = "xxxxxx"
ssl.KeyManagerPassword = "xxxxxxx"
srvr.SetSslConfiguration(ssl, SslPort)
'add filter to redirect all traffic from http to https (optional)
srvr.AddFilter("/*", "HttpsFilter", False)
End Sub
public Sub ValidarUsuario(ws As WebSocket, lblusernamemain As JQueryElement)
Try
If ws.Session.GetAttribute("id_usuario") = Null Or 0 = ws.Session.GetAttribute("id_usuario") Then
ws.Eval("document.location.replace('login.html')",Null)
Else
lblusernamemain.SetHtml(ws.Session.GetAttribute("nombre"))
End If
Catch
Log(LastException)
End Try
End Sub
thanks for your help