oauth2-azure
oauth2-azure copied to clipboard
The resource option in getAccessToken is ignored
The sample code in readme contains the following snippet.
$token = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code'],
'resource' => 'https://graph.windows.net',
]);
The resource
field is never applied as it is overwritten in the getAccessToken
method
if($this->authWithResource) {
$options['resource'] = $this->resource ? $this->resource : $this->urlAPI;
}
I am not sure whether this behaviour intended. However, it feels strange to use an ignored option in the official sample.
The paragraph Advanced flow following the code sample should clarify that.
The Authorization Code Grant Flow is a little bit different for Azure Active Directory. Instead of scopes, you specify the resource which you would like to access - there is a param
$provider->authWithResource
which will automatically populate theresource
param of request with the value of either$provider->resource
or$provider->urlAPI
. This feature is mostly intended for v2.0 endpoint of Azure AD (see more here).