AuthCallback
Auth.GetUserToken
Error
This error occurs when I run "wait for " before calling redirect
B4X:
Else If (req.GetParameter("code") <> "") Then
Log("code")
Try
Dim codeAuth As String = req.GetParameter("code")
Wait For(Auth.GetUserToken(codeAuth)) Complete (codeToken As String)
resp.SendRedirect("/lobby?session="&codeToken) ' THIS IS LINE 61
Catch
'Handle failure
resp.SendRedirect("/login.html")
End Try
end if
Auth.GetUserToken
B4X:
Sub GetUserToken(usercode As String) As ResumableSub
Dim j As HttpJob
j.Initialize("", Me)
j.PostString("https://mywebsite.com...",usercode)
j.GetRequest.SetContentType("application/x-www-form-urlencoded")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log("token = "&j.GetString)
Dim parser As JSONParser
parser.Initialize(j.GetString)
Dim root As Map = parser.NextObject
Dim access_token As String = root.Get("access_token")
Return access_token
End If
j.Release
End Sub
Error
B4X:
Error occurred on line: 61 (AuthCallback)
java.lang.IllegalStateException: Committed
at org.eclipse.jetty.server.HttpChannel.resetBuffer(HttpChannel.java:1138)
at org.eclipse.jetty.server.HttpOutput.resetBuffer(HttpOutput.java:1419)
at org.eclipse.jetty.server.Response.resetBuffer(Response.java:1255)
at org.eclipse.jetty.server.Response.sendRedirect(Response.java:592)
at org.eclipse.jetty.server.Response.sendRedirect(Response.java:526)
at org.eclipse.jetty.server.Response.sendRedirect(Response.java:601)
at anywheresoftware.b4j.object.JServlet$ServletResponseWrapper.SendRedirect(JServlet.java:406)
at b4j.example.authcallback$ResumableSub_Handle.resume(authcallback.java:276)
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:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
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.BA.raiseEvent(BA.java:98)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1119)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:47)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:43)
at anywheresoftware.b4a.shell.ShellBA.startMessageLoop(ShellBA.java:121)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:180)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:309)
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 b4j.example.main.main(main.java:29)
This error occurs when I run "wait for " before calling redirect