Wednesday, January 6, 2016

Azure Active Directory - Get Tenant Id from Tenant Name

This question "How do I get my Tenant Id?" has come up several times so I though I will blog it.

You can do that my going to https://login.windows.net/TenantName/.well-known/openid-configuration where TenantName is the one of the domain name of your tenant.

For example, https://login.windows.net/anujc.onmicrosoft.com/.well-known/openid-configuration will return

{"authorization_endpoint":"https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/authorize","token_endpoint":"https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/token","token_endpoint_auth_methods_supported":["client_secret_post","private_key_jwt"],"jwks_uri":"https://login.windows.net/common/discovery/keys","response_modes_supported":["query","fragment","form_post"],"subject_types_supported":["pairwise"],"id_token_signing_alg_values_supported":["RS256"],"response_types_supported":["code","id_token","code id_token","token id_token","token"],"scopes_supported":["openid"],"issuer":"https://sts.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/","claims_supported":["sub","iss","aud","exp","iat","auth_time","acr","amr","nonce","email","given_name","family_name","nickname"],"microsoft_multi_refresh_token":true,"check_session_iframe":"https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/checksession","end_session_endpoint":"https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/oauth2/logout","userinfo_endpoint":"https://login.windows.net/46650ea8-7413-4415-82c6-f891fc15a31e/openid/userinfo"}

This contains my Tenant Id 46650ea8-7413-4415-82c6-f891fc15a31e