Skip to content

Commit f7a0326

Browse files
committed
show error if domain invalid
1 parent e28944d commit f7a0326

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

AADInternals.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ def __init__(self, proxies={},use_cache=True,save_to_cache=True,tenant_id=None,c
5959

6060
if domain and (not tenant_id):
6161

62-
data = requests.get('https://login.microsoftonline.com/%s/.well-known/openid-configuration' % domain,proxies=proxies,verify=self.verify).content.decode('utf-8')
63-
tenant_id = json.loads(data)['token_endpoint'].split('https://login.microsoftonline.com/')[1].split('/')[0]
62+
data = json.loads(requests.get('https://login.microsoftonline.com/%s/.well-known/openid-configuration' % domain,proxies=proxies,verify=self.verify).content.decode('utf-8'))
63+
if data.get('error') == 'invalid_tenant':
64+
print(data['error_description'])
65+
sys.exit(1)
66+
tenant_id = data['token_endpoint'].split('https://login.microsoftonline.com/')[1].split('/')[0]
6467

6568
if not tenant_id:
6669
print('Error, Please provide tenant_id')

0 commit comments

Comments
 (0)