codekingpro/portable-devtools
114k
1# ------------------------------------2# Copyright (c) Microsoft Corporation.3# Licensed under the MIT License.4# ------------------------------------5from typing import Any, Iterable, Optional6 7from azure.core.exceptions import ClientAuthenticationError8 9 10class CredentialUnavailableError(ClientAuthenticationError):11 """The credential did not attempt to authenticate because required data or state is unavailable."""12 13 14class AuthenticationRequiredError(CredentialUnavailableError):15 """Interactive authentication is required to acquire a token.16 17 This error is raised only by interactive user credentials configured not to automatically prompt for user18 interaction as needed. Its properties provide additional information that may be required to authenticate. The19 control_interactive_prompts sample demonstrates handling this error by calling a credential's "authenticate"20 method.21 22 :param str scopes: Scopes requested during the failed authentication23 :param str message: An error message explaining the reason for the exception.24 :param str claims: Additional claims required in the next authentication.25 """26 27 def __init__(28 self, scopes: Iterable[str], message: Optional[str] = None, claims: Optional[str] = None, **kwargs: Any29 ) -> None:30 self._claims = claims31 self._scopes = scopes32 if not message:33 message = "Interactive authentication is required to get a token. Call 'authenticate' to begin."34 super(AuthenticationRequiredError, self).__init__(message=message, **kwargs)35 36 @property37 def scopes(self) -> Iterable[str]:38 """Scopes requested during the failed authentication.39 40 :rtype: ~typing.Iterable[str]41 """42 return self._scopes43 44 @property45 def claims(self) -> Optional[str]:46 """Additional claims required in the next authentication.47 48 :rtype: str or None49 """50 return self._claims51 