I have spent several hours the last two days trying to make a SAML authentication work. The exacts same code ported to PHP using cUrl worked fine, but not in B4A.
After much debugging and analyzing with
mitmproxy I finally realized that OkHttpUtils2 PostString
does not automatically encode the POST parameters. Instead, I had to use StringUtils.EncodeUrl:
Dim SU As StringUtils
saml = SU.EncodeUrl(saml, "UTF-8")
j.PostString(url, "SAMLResponse=" & saml)
Then it worked.
After I found the cause of the problems, I realized that I could also use PostMultipart which does not need url encoding:
Dim m As Map
m.Initialize
m.Put("SAMLResponse", saml)
j.PostMultipart(url, m, Null)
As far as I know, HttpUtils2 does not need encoding of the POST parameters.
Hopefully, this forum post can save others from wasting a few hours