Open david-navigator opened 2 months ago
I can't test this problem... but did you look at the documentation here
https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow
Specifically one of these
prompt=select_account
login_hint
domain_hint
Ah! Thanks I wasn't aware of these. I can see how they could be useful, especially if users have SSO enabled and so don't even get the choice of which account to use and I'll certainly look at implementing it. However in this specific scenario the customer was "clever" enough that they would have still used the wrong domain :)
Also... in recent versions of delphi instead of your Base64URLDecode
function you could replace it with TNetEncoding.Base64Url.Decode(Base64Str);
. I made a feature request for them to add it probably 3-5 years ago and they added it.
I've just spent a day trying to debug why this oAuth2 stuff was failing for a particular customer. Seems that the customer was telling my application that they were using the email address someone@mydomain.com, but when the Microsoft authentication browser window popped up, they were actually authenticating against someone@mydomain.net. (it seems that their Microsoft account supports both domains)
I can't find any reference as to how to get oAuth2 to work with different email addresses like this, and to be frank I doubt it does, so I've added some code to my implementation of IdSASL.Outh.Base.
I've copied it below in case it's of use to anyone else.