microsoftgraph / msgraph-sdk-php

Microsoft Graph Library for PHP.
Other
578 stars 144 forks source link

401 Unauthorized #291

Closed yvescleuder closed 4 years ago

yvescleuder commented 4 years ago

GuzzleHttp\Exception\ClientException Client error: 'GET https://api.powerbi.com/v1.0/myorg/groups/4aab859f-954e-45bf-b1d2-3ae5c6b3ee02/datasets' resulted in a '401 Unauthorized' response

Any function error 401; Autentication not getting token correct.

$provider = new \League\OAuth2\Client\Provider\GenericProvider([ 'clientId' => 'CLIENT ID APP', 'clientSecret' => <CLIENT SECRET APP', 'urlAuthorize' => 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize', 'urlAccessToken' => 'https://login.windows.net/4cd873f3-fb3c-4653-b537-a533816cd025/oauth2/token', 'urlResourceOwnerDetails' => '', 'scopes' => 'openid', ]);

        $accessToken = $provider->getAccessToken('client_credentials', [
            'username' => '<EMAIL AZURE>',
            'password' => '<PASSWORD AZURE>',
            'resource' => 'https://analysis.windows.net/powerbi/api'
        ]);

        $token = $accessToken->getToken();
        $client = new \Tngnt\PBI\Client($token);
        dd($client->dataset->getDatasets('4aab859f-954e-45bf-b1d2-3ae5c6b3ee02'));
MIchaelMainer commented 4 years ago

This client supports API calls to graph.microsoft.com. You are using api.powerbi.com.