How to find the tenant name
Category
- [x] Question
- [ ] Typo
- [ ] Additional article idea
Question
In a SPO App-Only environment, what is the recommended way on how to find the tenant name ( tenantname.onmicrosoft.com ) or sharepoint url, if the tenant id is available?
Alternatively, is there a way to open a (CSOM) ClientContext to the sharepoint admin url, with only the tenant id available?
The other way around (find tenant id by name) is easy and can be done by checking the openid configuration of the tenant: https://login.microsoftonline.com/tenantname.onmicrosoft.com/v2.0/.well-known/openid-configuration
Happy for any input on this.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
This is not possible to get Tenant Name based on Id using CSOM as it's always need SharePoint site url to create ClientContext firstly.
And if the envrionment is using App Only Authentication, the registered application can be found in:
http://tenant.sharepoint.com/sites/sitename/_layouts/15/_layouts/15/AppInv.aspx
The Tenantname should be know at first.
This issue is being closed as part of an issue list cleanup project. Issues with no activity in the past 6 months that aren't tracked by engineering as bugs were closed as part of this inititive. If this is still an issue, please follow the steps outlined to re-open or submit a new issue.
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues