Source code for azure.core.credentials_async

# ------------------------------------
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from __future__ import annotations
from types import TracebackType
from typing import Any, Optional, AsyncContextManager, Type
from typing_extensions import Protocol, runtime_checkable
from .credentials import AccessToken as _AccessToken

[docs]@runtime_checkable class AsyncTokenCredential(Protocol, AsyncContextManager["AsyncTokenCredential"]): """Protocol for classes able to provide OAuth tokens."""
[docs] async def get_token( self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, enable_cae: bool = False, **kwargs: Any, ) -> _AccessToken: """Request an access token for `scopes`. :param str scopes: The type of access needed. :keyword str claims: Additional claims required in the token, such as those returned in a resource provider's claims challenge following an authorization failure. :keyword str tenant_id: Optional tenant to include in the token request. :keyword bool enable_cae: Indicates whether to enable Continuous Access Evaluation (CAE) for the requested token. Defaults to False. :rtype: AccessToken :return: An AccessToken instance containing the token string and its expiration time in Unix time. """ ...
[docs] async def close(self) -> None: pass
async def __aexit__( self, exc_type: Optional[Type[BaseException]] = None, exc_value: Optional[BaseException] = None, traceback: Optional[TracebackType] = None, ) -> None: pass