Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
__init__.py57 linesDownload Raw Back to _internal
1# ------------------------------------2# Copyright (c) Microsoft Corporation.3# Licensed under the MIT License.4# ------------------------------------5from .aad_client import AadClient6from .aad_client_base import AadClientBase7from .auth_code_redirect_handler import AuthCodeRedirectServer8from .aadclient_certificate import AadClientCertificate9from .decorators import wrap_exceptions10from .interactive import InteractiveCredential11from .utils import (12    get_default_authority,13    normalize_authority,14    resolve_tenant,15    validate_scope,16    validate_tenant_id,17    within_credential_chain,18    within_dac,19)20 21 22def _scopes_to_resource(*scopes) -> str:23    """Convert a AADv2 scope to an AADv1 resource.24 25    :param str scopes: scope to convert26    :return: the first scope, converted to an AADv1 resource27    :rtype: str28    :raises: ValueError if scopes is empty or contains more than one scope29    """30 31    if len(scopes) != 1:32        raise ValueError("This credential requires exactly one scope per token request.")33 34    resource = scopes[0]35    if resource.endswith("/.default"):36        resource = resource[: -len("/.default")]37 38    return resource39 40 41__all__ = [42    "_scopes_to_resource",43    "AadClient",44    "AadClientBase",45    "AuthCodeRedirectServer",46    "AadClientCertificate",47    "get_default_authority",48    "InteractiveCredential",49    "normalize_authority",50    "resolve_tenant",51    "validate_scope",52    "within_credential_chain",53    "within_dac",54    "wrap_exceptions",55    "validate_tenant_id",56]57 
codekingpro/portable-devtools · Team Ai