Error when accesing Microsoft Graph via Php SDK

Sergiu Varga 6 Reputation points
2022-09-27T11:59:49.617+00:00

hello ,

I've tried to access my onedrive account using a php script that I need for a web application. However I get the following error:

Fatal error: Uncaught GuzzleHttp\Exception\ServerException: Server error: POST https://login.microsoftonline.com/......./oauth2/token resulted in a 500 Internal Server Error response:
{"error":"server_error","error_description":"AADSTS90036: An unexpected, non-retryable error stemming from the directory (truncated...)
in /home/weblamp/public_html/onedrive/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:

0 /home/weblamp/public_html/onedrive/vendor/guzzlehttp/guzzle/src/Middleware.php(69): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response), NULL, Array, NULL)

1 /home/weblamp/public_html/onedrive/vendor/guzzlehttp/promises/src/Promise.php(204): GuzzleHttp\Middleware::GuzzleHttp{closure}(Object(GuzzleHttp\Psr7\Response))

2 /home/weblamp/public_html/onedrive/vendor/guzzlehttp/promises/src/Promise.php(153): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), NULL)

3 /home/webla in /home/weblamp/public_html/onedrive/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113

Below my script :

require DIR . '/vendor/autoload.php';

use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;

$target_dir = "downloads/";

echo "<pre>";

$guzzle = new \GuzzleHttp\Client();

$tenantId = 'your_tenanet_id, e4c9ab4e-****-****-****-230ba2a757fb';
$clientId = 'your_app_id_registered_in_portal, dc175b96-****-****-****-ea03e56da5e7';
$clientSecret = 'app_key_generated_in_portal, /pGggH************************Zr732';

$url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token';
$user_token = json_decode($guzzle->post($url, [
'form_params' => [
'client_id' => $clientId,
'client_secret' => $clientSecret,
'resource' => 'https://graph.microsoft.com/',
'grant_type' => 'password',
'username' => '.....',
'password' => '...'
],
])->getBody()->getContents());
$user_accessToken = $user_token->access_token;

echo $user_accessToken;

I created a Azure directory app, set up the permissions, got the right app id, tenant id, secret however the issue still persist.

Please help.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,716 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,668 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2022-09-28T00:14:04+00:00

    Hi @Sergiu Varga

    Hope you're doing well.

    As per the AADSTS error code documentation by Microsoft, for error code AADSTS90036, you need to raise a Support case with Microsoft to get more details on it.

    Hope this helps.

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

  2. Sergiu Varga 6 Reputation points
    2022-09-28T07:53:26.19+00:00

    Thanks for your answer.

    Could you point towards where exactly should I send a support message ?