question

AlessioVietri-3981 avatar image
0 Votes"
AlessioVietri-3981 asked JamesTran-MSFT edited

[MSGRAPH] Unable to retrieve tenant service info

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-files
graph-problem.png (19.2 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AlessioVietri-3981
Thank you for your detailed post!

  • Are you able to share the documentation you followed to set this all up? This way I can gain a better understanding of your issue.

  • When you tested this with your test app, was this just a local test? Or did you use a test account too?

  • When using your 'real credentials' is this user associated with more than one tenant? If so, you might have to specify the tenant you're trying to connect to.

Any additional information or documentation would be greatly appreciated!


If you have any other questions, please let me know.
Thank you for your time and patience throughout this issue.

0 Votes 0 ·

Please, check my answer below, I don't know why the submit button is not working

0 Votes 0 ·

Hello again, could it be related to the Office 365 membership? Do I need a subscription for my personal account to make this work?

0 Votes 0 ·
AlessioVietri-3981 avatar image
0 Votes"
AlessioVietri-3981 answered JamesTran-MSFT converted comment to answer

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
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AlessioVietri-3981
Thank you for the quick response!

When it comes to the error message that you're receiving, I don't think it's related to your Office 365 membership, or not having a subscription on your personal account.


I've reached out to our engineering team to see if they can share any insights on this. In the meantime, if you'd like to reach the Microsoft Graph SDK for PHP team, feel free to submit an issue with them while I try to get an answer from my end as well.


If you have any other questions, please let me know.
Thank you for your time and patience throughout this issue.

0 Votes 0 ·

Hi, thanks a lot for your reply.

I just submitted an issue here:
https://github.com/microsoftgraph/msgraph-sdk-php/issues/404

I'll also wait for the answer from the engineering team.

Thanks again!

0 Votes 0 ·
JamesTran-MSFT avatar image
0 Votes"
JamesTran-MSFT answered AlessioVietri-3981 commented

@AlessioVietri-3981
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.

· 16
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks again. I don't think that this account is related to a SharePoint online subscription, also because when I get inside the Office 365 section, I can't see any SharePoint link. What do I need to activate/enable to use this feature then?

Regarding Graph Explorer, everything worked fine inside that area, but yes, I think that it could be related to the token type. I need to use client credentials because I need to make my flow work like my test account used to, I don't want to change it.

So, if you can tell what I need to activate/enable to make this work (also with a paid subscription) it would be great!

Thanks in advance

0 Votes 0 ·

@AlessioVietri-3981
Thank you for the quick follow up!

From the GitHub doc that you followed - Get started with the PHP Connect Sample, there's another link to a PHP Connect Sample (which is being archived and replaced), but it states that you need:

  • Either a Microsoft account or Office 365 for Business account. You can sign up for an Office 365 Developer subscription that includes the resources that you need to start building Office 365 apps.

  • PHP 5.6^ or 7

  • Composer, a dependency manager for PHP



I'll double check the requirements with my team and follow up as soon as possible.
Thank you for your time and patience throughout this issue.

0 Votes 0 ·

Ok, thanks a lot for your help!

0 Votes 0 ·
Show more comments