File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from abc import ABC , abstractmethod
4
4
5
- from azure .identity import DefaultAzureCredential
5
+ import logging
6
+
7
+ from azure .identity import (
8
+ DefaultAzureCredential ,
9
+ CredentialUnavailableError ,
10
+ )
6
11
from azure .core .credentials import AccessToken
12
+ from azure .core .exceptions import ClientAuthenticationError
7
13
8
14
9
15
class TokenProvider (ABC ):
@@ -35,5 +41,12 @@ def __init__(self) -> None:
35
41
self ._credential = DefaultAzureCredential ()
36
42
37
43
def get_token (self ) -> str :
38
- access_token : AccessToken = self ._credential .get_token (self ._SCOPE )
44
+ try :
45
+ access_token : AccessToken = self ._credential .get_token (self ._SCOPE )
46
+ except (CredentialUnavailableError , ClientAuthenticationError ):
47
+ logging .error ("=" * 60 )
48
+ logging .error ("Azure credentials required. Please run 'az login'." )
49
+ logging .error ("=" * 60 )
50
+ raise
51
+
39
52
return access_token .token
You can’t perform that action at this time.
0 commit comments