Get Office 365 Tenant ID from Domain Name

OpenID Connect describes a metadata document that contains most of the information required for an app to do sign-in. This includes information such as the authorization endpoint, token endpoint, tenant region scope, etc. For the discovery endpoint, this is the OpenID Connect metadata document you should use:

The {domain} can take one of two values:

ValueDescription
commonUsers with both a personal Microsoft account and a work or school account from Azure AD can sign in to the application.
contoso.comThe friendly domain name of the Office 365 tenant

The metadata is a simple JSON. See the following snippet for an example.

To get the tenant ID, we just need to parse the token_endpoint property as shown below:

We will get the following JSON for the invalid domain name.

Sample PowerApps using the above mentioned endpoint

Hope this helps. Sharing is Caring !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.