Document issue
"Microsoft Application Registration Portal (Recommended): Register a new application that authenticates using the v2.0 authentication endpoint. This endpoint authenticates both personal (Microsoft) and work or school (Azure Active Directory) accounts."
Seems to be deprecated
AB#7355
Hello, I noticed this point too
<?php
require_once("vendor/autoload.php");
$guzzle = new \GuzzleHttp\Client();
$url = 'https://login.microsoftonline.com/iiiiiiiiiiiiiiii-iiiii-iiii-iiiii-iiiiiiiiiiiiiiiiii/oauth2/v2.0/token';
$token = json_decode($guzzle->post($url, [
'form_params' => [
'client_id' => 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx',
'client_secret' => 'ssssssssssssssssssssss',
'resource' => 'https://graph.microsoft.com/',
'grant_type' => 'client_credentials',
],
])->getBody()->getContents());
$accessToken = $token->access_token;
var_dump($accessToken);
generates
PHP Fatal error: Uncaught GuzzleHttp\Exception\ClientException: Client error: `POST https://login.microsoftonline.com/iiiiiiiiiiiiiiii-iiiii-iiii-iiiii-iiiiiiiiiiiiiiiiii/oauth2/v2.0/token` resulted in a `400 Bad Request` response:
{"error":"invalid_request","error_description":"AADSTS901002: The 'resource' request parameter is not supported.\r\nTrac (truncated...)
in /root/teste/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
#0 /root/teste/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\Exception\RequestException::create(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response))
#1 /root/teste/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\Middleware::GuzzleHttp\{closure}(Object(GuzzleHttp\Psr7\Response))
#2 /root/teste/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\Promise\Promise::callHandler(1, Object(GuzzleHttp\Psr7\Response), Array)
#3 /root/teste/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}()
#4 /r in /root/teste/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 113
$url = 'https://login.microsoftonline.com/iiiiiiiiiiiiiiii-iiiii-iiii-iiiii-iiiiiiiiiiiiiiiiii/oauth2/token'; url /oauth2/token work normally was it right or was it somehow wrong?
(i am iniciant in api)
Don't remember anymore, but maybe i changed to another code example & library. Here is good example:
https://github.com/OfficeDev/Groups-API-Office-Add-in-PHP-Sample/blob/master/mygroups/AuthHelper.php "microsoft/microsoft-graph": "^1.12", "thenetworg/oauth2-azure": "^1.4"
Hello @JukkaHau,
Could you please expand a bit more on this issue? What is deprecated?
Kind regards,
Isaac Vargas
Authentication code snippet in README is fixed for v1 removing the resource parameter from the body.
v2 preview abstracts away this issue using the Authentication Provider.