55# ------------------------------------------------------------------------------
66
77from knack .log import get_logger
8+ from typing import Any , Optional
89
910import os
1011import abc
@@ -32,19 +33,19 @@ def __init__(self, *args, **kwargs):
3233
3334 @abc .abstractmethod
3435 def acquire_token (self , * scopes , ** kwargs ):
35- # type: (*str, **Any) -> Optional[AccessToken ]
36+ # type: (*str, **Any) -> Optional[Any ]
3637 """
3738 Attempt to acquire an access token from a cache or by redeeming a
3839 refresh token
3940 """
4041
4142 @abc .abstractmethod
4243 def request_token (self , * scopes , ** kwargs ):
43- # type: (*str, **Any) -> AccessToken
44+ # type: (*str, **Any) -> Any
4445 """Request an access token"""
4546
4647 def should_refresh (self , token ):
47- # type: (AccessToken ) -> bool
48+ # type: (Any ) -> bool
4849 now = int (time .time ())
4950 if token .expires_on - now > BaseTokenMixin .DEFAULT_REFRESH_OFFSET :
5051 return False
@@ -56,7 +57,7 @@ def should_refresh(self, token):
5657 return True
5758
5859 def get_token (self , * scopes , ** kwargs ):
59- # type: (*str, **Any) -> AccessToken
60+ # type: (*str, **Any) -> Any
6061 """
6162 Request an access token for `scopes`.
6263
@@ -89,7 +90,7 @@ def __init__(self, scopes=None):
8990
9091 # override
9192 def get_token (self , * scopes , ** kwargs ):
92- # type: (*str, **Any) -> AccessToken
93+ # type: (*str, **Any) -> Any
9394 """
9495 Request an access token for `scopes`.
9596 """
@@ -113,7 +114,7 @@ def get_token(self, *scopes, **kwargs):
113114
114115 # override
115116 def acquire_token (self , * scopes ):
116- # type: (*str) -> Optional[AccessToken ]
117+ # type: (*str) -> Optional[Any ]
117118 """
118119 Attempt to acquire an access token from a cache or by redeeming
119120 a refresh token.
@@ -125,16 +126,13 @@ def acquire_token(self, *scopes):
125126 azure_folder = get_config_dir ()
126127 ACCOUNT .load (os .path .join (azure_folder , "azureProfile.json" ))
127128 p = Profile (storage = ACCOUNT )
128- cred , subscription_id , tenant_id = p .get_login_credentials ()
129+ cred , _ , _ = p .get_login_credentials ()
129130 scopes = ["https://management.azure.com/.default" ]
130131 access_token = cred .get_token (* scopes )
131132
132133 return access_token
133134
134135 # override
135136 def request_token (self , * scopes , ** kwargs ):
136- # TODO: Impl refresh logic if possible. For now we give error
137- # to az login again
138- return super (ArcDataCliCredential , self ).request_token (
139- * scopes , ** kwargs
140- )
137+ # TODO: Implement refresh logic if possible. For now, raise an error to prompt az login again.
138+ raise NotImplementedError ("Token refresh logic not implemented. Please run 'az login' again." )
0 commit comments