Not correct token

Neil Betrue 1 Reputation point
2022-03-14T02:07:56.107+00:00

Code below:

I have given permissions to my app to read my email. I can get the access token but not correct one. When it asks me to login it says user not found?

$curl = curl_init();
$auth_data = array(
"Content-Type: application/x-www-form-urlencoded",
'client_id' => 'my-client-id',
'response_type' => 'code',
'redirect_uri' => 'https://myurl.com/authorize.php',
'response_mode' => 'query',
'scope' => 'https://graph.microsoft.com/.default',
'state' => '12345'
);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $auth_data);
curl_setopt($curl, CURLOPT_URL, "https://login.microsoftonline.com/{my_tenant_id}/oauth2/v2.0/authorize");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
//echo $result;
var_dump($result);
//print_r($result);

I can get an access token from this link https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token
but get this error:
{"error":{"code":"BadRequest","message":"/me request is only valid with delegated authentication flow.",

Please help

Microsoft Authenticator
Microsoft Authenticator
A Microsoft app for iOS and Android devices that enables authentication with two-factor verification, phone sign-in, and code generation.
6,152 questions
0 comments No comments
{count} votes