I am trying to create a simple PHP script that uses oAuth and I seem to require the Tenant ID of my SharePoint Online account. I'm sure this is something very straight forward, but I can't seem to locate it.



I found this approach (blog.scoreman.net) easier:

Navigate to https://.sharepoint.com/_layouts/appprincipals.aspx. Identify the row with your registered application and look at the App Identifier column. The unique identifier after the @-sign in the App Identifier is the app realm. Copy the realm (not the whole App Identifier just the last part after the @-sign).


easiest approach which does not require authentication is here.

for SharePoint Online and Office 365 Tenant id is the same as Azure directory id.


above URL will return JSON for open id connect. Extract guid from token_endpoint property. extracted GUID is your Tenant Id(Tenant Id and directory id is same)


Tenant ID is nothing but SharePoint Online Site Realm.

You can get this by having a REST call to the site API.

Follow below steps:

Header: Authorization: Bearer

  • Get the Bearer realm component from the response header and save it.

Check the below post for complete step to be followed:


  • This throws exception 'Access denied. You do not have permission to perform this action or access this resource'
    – Sagar S.
    Dec 28 '20 at 11:33

You can get the the Tenant ID from the Azure Active Directory admin center. Navigate to https://aad.portal.azure.com/ and the select Azure Active Directory in the left navigation. The Overview page displays the Tenant ID.

Azure Active Directory admin center

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.