Hello,
I am trying to convert a B4J command-line application that uses FCMPush to a B4J UI application. However, when I move all the functions to the UI, I am encountering an error specifically in the GetToken function.
Has anyone experienced similar issues or have any advice on why the command-line version works, but the UI version fails at this point?
Any help or guidance would be appreciated.
Thank you!
Error :
I am trying to convert a B4J command-line application that uses FCMPush to a B4J UI application. However, when I move all the functions to the UI, I am encountering an error specifically in the GetToken function.
Has anyone experienced similar issues or have any advice on why the command-line version works, but the UI version fails at this point?
Any help or guidance would be appreciated.
Thank you!
B4X:
Private Sub GetTokenValue (FilePath As String) As String
Dim GoogleCredentials As JavaObject
GoogleCredentials.InitializeStatic("com.google.auth.oauth2.GoogleCredentials")
Dim Credentials As JavaObject = GoogleCredentials.RunMethodJO("fromStream", Array(File.OpenInput(FilePath, ""))) _
.RunMethod("createScoped", Array(Array As String("https://www.googleapis.com/auth/firebase.messaging")))
Credentials.RunMethod("refreshIfExpired", Null)
Return Credentials.RunMethodJO("getAccessToken", Null).RunMethod("getTokenValue", Null)
End Sub
Error :
B4X:
Credentials.RunMethod("refreshIfExpired", Null) ' java.lang.reflect.InvocationTargetException