I'm following this documentation: https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code
Under, REQUEST AN AUTHORIZATION CODE, it gives a sample code involving an endpoint for OAuth 2.0
. I've followed this structure to base my own request resembling:
https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=code
&redirect_uri=https://example.com
&response_mode=query
&resource=6731de76-14a6-49ae-97bc-6eba6914391e
&state=12345
During my tests, I've even tried (getting the request as bare as possible):
https://login.microsoftonline.com/{tenant}/oauth2/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=code
Here's the interesting thing: If I access these domains through the browser, they return a "successful" call, like so:
https://example.com/?code=AOA...................................
However, I can't seem to get this same result (acquire a code) through a PHP
workaround.
I've tried:
file_get_contents($my_url);
But all that returns is an error and a login page for Microsoft.
I've also tried doing so in cURL
, but no luck.
Can anyone advise on how to replicate getting such a code (automatically)?