'Not in Erel's sample. Added from https://www.b4x.com/android/forum/threads/logging-in-to-ms-365.148816/
Sub GetTokenImpl(authCode As String) As ResumableSub 'añadido de MSLOGIN
Log("GetTokenImpl: " & authCode)
Dim params As Map
params.Initialize
params.Put("client_id", mClientId)
params.Put("code", authCode)
params.Put("redirect_uri", redirectURI)
params.Put("grant_type", "authorization_code")
Dim sb As StringBuilder
sb.Initialize
For Each key As String In params.Keys
sb.Append(key).Append("=").Append(params.Get(key)).Append("&")
Next
sb.Remove(sb.Length - 1, sb.Length) ' Remove the last "&"
Dim hc As OkHttpClient
hc.Initialize("hc")
Dim req As OkHttpRequest
req.InitializePost2($"https://login.microsoftonline.com/${mTenant}/oauth2/v2.0/token"$, sb.ToString.GetBytes("UTF8"))
hc.Execute(req, 1)
Log("Llega aquí")
Wait For hc_ResponseSuccess (Response As OkHttpResponse, TaskId As Int)
Log("Response: " & Response.GetHeaders)
If TaskId = 1 Then
Log("TaksId = 1") '<------ The sub doesn't reach this line
Response.GetAsynchronously("response", File.OpenOutput(xui.DefaultFolder, "response.txt", False), True, TaskId)
Wait For response_StreamFinish (Success As Boolean, TaskId As Int)
If Success Then
Dim parser As JSONParser
parser.Initialize(File.ReadString(xui.DefaultFolder, "response.txt"))
TokenInformationFromResponse(File.ReadString(xui.DefaultFolder, "response.txt"))
Else
Log("Error: " & LastException.Message)
ResetToken
RaiseEvent(False)
End If
Return Null
End If
Return Null
End Sub