I have set up an Azure app for which I defined 2 redirect URLs, one for testing on localhost and the other for testing in an online demo environment: http://localhost/myproject/auth
and https://demo.myproject.com/auth
.
In my PHP app I construct this URL to get an authentication code, which I then use to retrieve my access and refresh tokens (line breaks are for readability):
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?
client_id=aaaaaaaaa-...-...-...-...
&scope=User.Read+Mail.ReadWrite+offline_access
&response_type=code
&redirect_url=http%3A%2F%2Flocalhost%2Fmyproject%2Fauth <-- I want to be redirected to localhost
&state=wWpmDDGFZuDAI
After logging in, I should be redirected to http://localhost/myproject/auth
, as specified in the URL above, but I'm being redirected to https://demo.myproject.com/auth
instead.
If I remove https://demo.myproject.com/auth
from the Azure app, everything works as expected.
As soon as I add it back, I'm being redirected to it, even though the localhost URL is specified as redirect_url.
I tried resetting the laptop, clearing the browser cache completely, even installed a new browser and tried logging in from that one, to no success.
Why does this happen?