Skip to content

Commit 4ab91fa

Browse files
committed
Simplify and easier debugging
1 parent bd931a2 commit 4ab91fa

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

msal/authority.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,14 @@ def tenant_discovery(tenant_discovery_endpoint, http_client, **kwargs):
174174
# Returns Openid Configuration
175175
resp = http_client.get(tenant_discovery_endpoint, **kwargs)
176176
if resp.status_code == 200:
177-
payload = json.loads(resp.text) # It could raise ValueError
178-
if 'authorization_endpoint' in payload and 'token_endpoint' in payload:
179-
return payload # Happy path
180-
raise ValueError("OIDC Discovery does not provide enough information")
177+
return json.loads(resp.text) # It could raise ValueError
181178
if 400 <= resp.status_code < 500:
182179
# Nonexist tenant would hit this path
183180
# e.g. https://login.microsoftonline.com/nonexist_tenant/v2.0/.well-known/openid-configuration
184-
raise ValueError(
185-
"OIDC Discovery endpoint rejects our request. Error: {}".format(
186-
resp.text # Expose it as-is b/c OIDC defines no error response format
181+
raise ValueError("OIDC Discovery failed on {}. HTTP status: {}, Error: {}".format(
182+
tenant_discovery_endpoint,
183+
resp.status_code,
184+
resp.text, # Expose it as-is b/c OIDC defines no error response format
187185
))
188186
# Transient network error would hit this path
189187
resp.raise_for_status()

0 commit comments

Comments
 (0)