B4J Question Trying to use Google Drive and Upload... but getting invalid_grant

Magma

Expert
Licensed User
Longtime User
Hi there...

tried some examples found in forum for using Google Drive... created api and anything needed but getting this error:

Waiting for debugger to connect...
Program started.
*** mainpage: B4XPage_Created
GoogleDrive Initiaize
GoogleDrive ConnectToDrive
GoogleDrive, Access Token request
Getting access token from refresh token...
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
ResponseError. Reason: , Response: {
"error": "invalid_grant",
"error_description": "Bad Request"
}
Error occurred on line: 205 (GoogleOAuth2)
java.lang.ClassCastException: class java.lang.String cannot be cast to class b4j.example.googleoauth2$_tokeninformation (java.lang.String is in module java.base of loader 'bootstrap'; b4j.example.googleoauth2$_tokeninformation is in unnamed module of loader 'app')
at b4j.example.googledrive$ResumableSub_ConnectToDrive.resume(googledrive.java:152)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:514)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:494)
at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:568)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)

I am uploading a simple project to test it may be with your client id & secret... or if someone have idea what happens...

Thanks in advance !
 

Attachments

  • GDrive_Upload.zip
    11.8 KB · Views: 64
Last edited:

Magma

Expert
Licensed User
Longtime User
...well, actually it seems the same.. because coppied from there...
but... first time getting token...

Waiting for debugger to connect...
Program started.
*** mainpage: B4XPage_Created
GoogleDrive Initiaize
GoogleDrive ConnectToDrive
GoogleDrive, Access Token request
*** mainpage: B4XPage_Appear
*** mainpage: B4XPage_Resize [mainpage]
Getting access token from authorization code...
Token received. Expires: 04/18/2023 10:29:19
Error occurred on line: 189 (GoogleOAuth2)
java.lang.ClassCastException: class java.lang.String cannot be cast to class b4j.example.googleoauth2$_tokeninformation (java.lang.String is in module java.base of loader 'bootstrap'; b4j.example.googleoauth2$_tokeninformation is in unnamed module of loader 'app')
at b4j.example.googledrive$ResumableSub_ConnectToDrive.resume(googledrive.java:152)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:111)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:156)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:105)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:100)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:514)
at anywheresoftware.b4a.keywords.Common.access$0(Common.java:494)
at anywheresoftware.b4a.keywords.Common$CallSubDelayedHelper.run(Common.java:568)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
at java.base/java.lang.Thread.run(Thread.java:834)

may it is something from my local-firewall... because i am seeing an empty page at browser (edge) opening 127.0.0.1:51067 and after reloading-page (2-3 times manually - pressing enter at the address bar)... :-(

What is the right procedure... from running side ?

Press run at b4j...
opens browser... and selecting google account - then asking for permissions for a not tested app... and then continues to this address: 127.0.0.1:51067...
... then my at log side (after hitting manual enter - that i think must not happening)
...
Getting access token from authorization code...
Token received. Expires: 04/18/2023 10:29:19
Error occurred on line: 189 (GoogleOAuth2)


ps: IF i delete that dat file created into dir.app then repeating the same.......
 
Upvote 0
Top