[MSGRAPH] Unable to retrieve tenant service info

Alessio Vietri 1 Reputation point
2021-02-23T11:43:05.16+00:00

Hello everyone,
I managed to connect my Laravel Application with a test account on Azure Active Directory using the official Microsoft Graph PHP package. I followed the guides to create an app on AAD, set the permissions etc. Everything worked like a charm. Then, I simply changed the credentials with the ones from my real account and now I get this error:

71124-graph-problem.png

I've set the correct permissions inside my real app, as I did inside my test app. I already tried with Graph Explorer and everything works fine

Any suggestion to fix this?

Thanks in advance

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,569 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Alessio Vietri 1 Reputation point
    2021-02-26T08:30:35.567+00:00

    Hi,
    Thanks a lot for your reply. This is the documentation I followed: https://github.com/microsoftgraph/msgraph-sdk-php
    and this is my code:

        $tenantId = '--------------';
        $clientId = '--------------';
        $clientSecret = '--------------';
        $guzzle = new \GuzzleHttp\Client();
        $url = 'https://login.microsoftonline.com/' . $tenantId . '/oauth2/token?api-version=beta';
        $token = json_decode($guzzle->post($url, [
            'form_params' => [
                'client_id' => $clientId,
                'client_secret' => $clientSecret,
                'resource' => 'https://graph.microsoft.com/',
                'grant_type' => 'client_credentials',
            ],
        ])->getBody()->getContents());
        $accessToken = $token->access_token;
        $graph = new \Microsoft\Graph\Graph();
        $graph->setBaseUrl("https://graph.microsoft.com/")
            ->setApiVersion("beta")
            ->setAccessToken($accessToken);
        ...
    

    so I think I'm specifying the correct tenant to point, right?

    For my tests, I used a brand new test account, not my original one.


  2. JamesTran-MSFT 36,366 Reputation points Microsoft Employee
    2021-03-02T16:38:34.193+00:00

    @Alessio Vietri
    Thank you for your time and patience throughout this issue! I received a response from our engineering team and it looks like this could potentially be related to your O365 License.

    Update:

    • Can you make sure the tenant has a valid SharePoint online subscription. Looks like the test user does not have an O365 license. Can you please verify?
    • Need clarification from customer on what exactly was working on Graph Explorer - Graph Explorer uses User token, but it looks like the customer is using client credential flow to get the token. Client credential flow will not work in Graph Explorer.
    • Can you please ask customer to verify by logging in with the test user (non working) in Graph Explorer to see if they can access the drive items from the test account too?

    If the license is not the issue, can you share the inner error details, (request id an timestamp).

    If you have any other questions, please let me know.