I have developed an MVC application enabled single sign on with Office 365. I want retrieve SharePoint tenant URL after logged in.

Example: Suppose I have logged in with user@contoso.onmicrosoft.com. I can build the SharePoint tenant URL with by taking contoso name from the user principal and building the URL like https://contoso-admin.sharepoint.com. This is working fine however if multi domain exist in single tenant I am unable to retrieve the URL when other domain user logged in

Example: If user1@domain2.onmicrosoft.com my SharePoint tenant URL building like https://domain2-admin.sharepoint.com but SharePoint tenant url same like https://contoso-admin.sharepoint.com.

Thanks in advance.


Use https://graph.microsoft.com/v1.0/sites/root endpoint. Look for webUrl property.

| improve this answer | |

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.