The code works in B4J debug mode and in Release mode only when SingleThreadHandler is set to True
is it possible to make it work with Mulithread or is it safe to use SingleThreadHandler = True
b4j2:
srvr.AddHandler("/" & ABMShared.AppName & "/api", "Services", True) ' OPTIONAL
b4j:
Log("GetBearerToken")
Dim Job As HttpJob
Job.Initialize("token", Me)
Job.PostString(tokenurl, "")
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
Job.GetRequest.SetHeader("Authorization", GetBasicAuthHeader(tokenclient,tokenclientsecret))
Job.GetRequest.SetHeader("x-api-key", tokenapikey)
Wait For (Job) JobDone(Job As HttpJob)
If Job.Success Then
Log("Done")
' Log(Job.GetString)
Try
Dim tokenmap As Map = ABMShared.Json2Map(Job.GetString)
Log(tokenmap)
Catch
Log(LastException)
End Try
End If
Job.Release
b4j2:
Sub GetBasicAuthHeader(clientId As String, clientSecret As String) As String
Dim su As StringUtils
Dim auth As String = clientId & ":" & clientSecret
Dim b() As Byte = auth.GetBytes("UTF8")
Dim encoded As String = su.EncodeBase64(b)
Return "Basic " & encoded
End Sub
is it possible to make it work with Mulithread or is it safe to use SingleThreadHandler = True