|
| 1 | +from collections.abc import Mapping, MutableMapping |
| 2 | +from logging import Logger |
| 3 | +from typing import Any, Final, Protocol, type_check_only |
| 4 | +from typing_extensions import deprecated |
| 5 | + |
| 6 | +from .auth_scheme import PopAuthScheme |
| 7 | +from .authority import Authority, AuthorityBuilder |
| 8 | +from .oauth2cli import Client |
| 9 | +from .oauth2cli.http import _HttpClientLike |
| 10 | +from .throttled_http_client import ThrottledHttpClient |
| 11 | +from .token_cache import TokenCache |
| 12 | +from .wstrust_response import * |
| 13 | + |
| 14 | +logger: Logger |
| 15 | + |
| 16 | +@type_check_only |
| 17 | +class _OnBeforeLaunchingUI(Protocol): |
| 18 | + # Called as on_before_launching_ui(ui="browser") or on_before_launching_ui(ui="broker"). |
| 19 | + def __call__(self, *, ui: str) -> object: ... |
| 20 | + |
| 21 | +def extract_certs(public_cert_content: str) -> list[str]: ... |
| 22 | + |
| 23 | +class ClientApplication: |
| 24 | + ACQUIRE_TOKEN_SILENT_ID: str |
| 25 | + ACQUIRE_TOKEN_BY_REFRESH_TOKEN: str |
| 26 | + ACQUIRE_TOKEN_BY_USERNAME_PASSWORD_ID: str |
| 27 | + ACQUIRE_TOKEN_ON_BEHALF_OF_ID: str |
| 28 | + ACQUIRE_TOKEN_BY_DEVICE_FLOW_ID: str |
| 29 | + ACQUIRE_TOKEN_FOR_CLIENT_ID: str |
| 30 | + ACQUIRE_TOKEN_BY_AUTHORIZATION_CODE_ID: str |
| 31 | + ACQUIRE_TOKEN_INTERACTIVE: str |
| 32 | + ACQUIRE_TOKEN_BY_USER_FIC_ID: str |
| 33 | + GET_ACCOUNTS_ID: str |
| 34 | + REMOVE_ACCOUNT_ID: str |
| 35 | + ATTEMPT_REGION_DISCOVERY: bool |
| 36 | + DISABLE_MSAL_FORCE_REGION: bool |
| 37 | + client_id: str |
| 38 | + client_credential: str | dict[str, Any] | None |
| 39 | + client_claims: Mapping[str, Any] | None |
| 40 | + http_client: ThrottledHttpClient |
| 41 | + app_name: str | None |
| 42 | + app_version: str | None |
| 43 | + authority: Authority |
| 44 | + token_cache: TokenCache |
| 45 | + client: Client |
| 46 | + authority_groups: dict[str, list[set[str]]] |
| 47 | + def __init__( |
| 48 | + self, |
| 49 | + client_id: str, |
| 50 | + client_credential: str | dict[str, Any] | None = None, |
| 51 | + authority: str | AuthorityBuilder | None = None, |
| 52 | + validate_authority: bool = True, |
| 53 | + token_cache: TokenCache | None = None, |
| 54 | + http_client: _HttpClientLike | None = None, |
| 55 | + verify: bool | str = True, |
| 56 | + proxies: Mapping[str, str] | None = None, |
| 57 | + timeout: float | tuple[float, float] | tuple[float, None] | None = None, |
| 58 | + client_claims: Mapping[str, Any] | None = None, |
| 59 | + app_name: str | None = None, |
| 60 | + app_version: str | None = None, |
| 61 | + client_capabilities: list[str] | None = None, |
| 62 | + azure_region: str | bool | None = None, |
| 63 | + exclude_scopes: list[str] | None = None, |
| 64 | + http_cache: MutableMapping[str, Any] | None = None, |
| 65 | + instance_discovery: bool | None = None, |
| 66 | + allow_broker: bool | None = None, |
| 67 | + enable_pii_log: bool | None = None, |
| 68 | + oidc_authority: str | None = None, |
| 69 | + ) -> None: ... |
| 70 | + def is_pop_supported(self) -> bool: ... |
| 71 | + def initiate_auth_code_flow( |
| 72 | + self, |
| 73 | + scopes: list[str], |
| 74 | + redirect_uri: str | None = None, |
| 75 | + state: str | None = None, |
| 76 | + prompt: str | None = None, |
| 77 | + login_hint: str | None = None, |
| 78 | + domain_hint: str | None = None, |
| 79 | + claims_challenge: str | None = None, |
| 80 | + max_age: int | None = None, |
| 81 | + response_mode: str | None = None, |
| 82 | + ) -> dict[str, Any]: ... |
| 83 | + @deprecated("Change your get_authorization_request_url() to initiate_auth_code_flow()") |
| 84 | + def get_authorization_request_url( |
| 85 | + self, |
| 86 | + scopes: list[str], |
| 87 | + login_hint: str | None = None, |
| 88 | + state: str | None = None, |
| 89 | + redirect_uri: str | None = None, |
| 90 | + response_type: str = "code", |
| 91 | + prompt: str | None = None, |
| 92 | + nonce: str | None = None, |
| 93 | + domain_hint: str | None = None, |
| 94 | + claims_challenge: str | None = None, |
| 95 | + **kwargs: Any, |
| 96 | + ) -> str: ... |
| 97 | + def acquire_token_by_auth_code_flow( |
| 98 | + self, auth_code_flow: dict[str, Any], auth_response: dict[str, Any], scopes: list[str] | None = None, **kwargs: Any |
| 99 | + ) -> dict[str, Any]: ... |
| 100 | + @deprecated("Change your acquire_token_by_authorization_code() to acquire_token_by_auth_code_flow()") |
| 101 | + def acquire_token_by_authorization_code( |
| 102 | + self, |
| 103 | + code: str, |
| 104 | + scopes: list[str], |
| 105 | + redirect_uri: str | None = None, |
| 106 | + nonce: str | None = None, |
| 107 | + claims_challenge: str | None = None, |
| 108 | + forwarded_client_claims: str | None = None, |
| 109 | + **kwargs: Any, |
| 110 | + ) -> dict[str, Any]: ... |
| 111 | + def get_accounts(self, username: str | None = None) -> list[dict[str, Any]]: ... |
| 112 | + def remove_account(self, account: Mapping[str, Any]) -> None: ... |
| 113 | + def acquire_token_silent( |
| 114 | + self, |
| 115 | + scopes: list[str], |
| 116 | + account: Mapping[str, Any] | None, |
| 117 | + authority: str | None = None, |
| 118 | + force_refresh: bool | None = False, |
| 119 | + claims_challenge: str | None = None, |
| 120 | + forwarded_client_claims: str | None = None, |
| 121 | + auth_scheme: PopAuthScheme | None = None, |
| 122 | + **kwargs: Any, |
| 123 | + ) -> dict[str, Any] | None: ... |
| 124 | + def acquire_token_silent_with_error( |
| 125 | + self, |
| 126 | + scopes: list[str], |
| 127 | + account: Mapping[str, Any] | None, |
| 128 | + authority: str | None = None, |
| 129 | + force_refresh: bool | None = False, |
| 130 | + claims_challenge: str | None = None, |
| 131 | + forwarded_client_claims: str | None = None, |
| 132 | + auth_scheme: PopAuthScheme | None = None, |
| 133 | + **kwargs: Any, |
| 134 | + ) -> dict[str, Any] | None: ... |
| 135 | + def acquire_token_by_refresh_token(self, refresh_token: str, scopes: list[str], **kwargs: Any) -> dict[str, Any]: ... |
| 136 | + def acquire_token_by_username_password( |
| 137 | + self, |
| 138 | + username: str, |
| 139 | + password: str, |
| 140 | + scopes: list[str], |
| 141 | + claims_challenge: str | None = None, |
| 142 | + auth_scheme: PopAuthScheme | None = None, |
| 143 | + **kwargs: Any, |
| 144 | + ) -> dict[str, Any]: ... |
| 145 | + |
| 146 | +class PublicClientApplication(ClientApplication): |
| 147 | + DEVICE_FLOW_CORRELATION_ID: Final = "_correlation_id" |
| 148 | + CONSOLE_WINDOW_HANDLE: Final[object] |
| 149 | + def __init__( |
| 150 | + self, |
| 151 | + client_id: str, |
| 152 | + client_credential: None = None, |
| 153 | + *, |
| 154 | + enable_broker_on_windows: bool | None = None, |
| 155 | + enable_broker_on_mac: bool | None = None, |
| 156 | + enable_broker_on_linux: bool | None = None, |
| 157 | + enable_broker_on_wsl: bool | None = None, |
| 158 | + authority: str | AuthorityBuilder | None = None, |
| 159 | + validate_authority: bool = True, |
| 160 | + token_cache: TokenCache | None = None, |
| 161 | + http_client: _HttpClientLike | None = None, |
| 162 | + verify: bool | str = True, |
| 163 | + proxies: Mapping[str, str] | None = None, |
| 164 | + timeout: float | tuple[float, float] | tuple[float, None] | None = None, |
| 165 | + client_claims: Mapping[str, Any] | None = None, |
| 166 | + app_name: str | None = None, |
| 167 | + app_version: str | None = None, |
| 168 | + client_capabilities: list[str] | None = None, |
| 169 | + azure_region: str | bool | None = None, |
| 170 | + exclude_scopes: list[str] | None = None, |
| 171 | + http_cache: MutableMapping[str, Any] | None = None, |
| 172 | + instance_discovery: bool | None = None, |
| 173 | + allow_broker: bool | None = None, |
| 174 | + enable_pii_log: bool | None = None, |
| 175 | + oidc_authority: str | None = None, |
| 176 | + ) -> None: ... |
| 177 | + def acquire_token_interactive( |
| 178 | + self, |
| 179 | + scopes: list[str], |
| 180 | + prompt: str | None = None, |
| 181 | + login_hint: str | None = None, |
| 182 | + domain_hint: str | None = None, |
| 183 | + claims_challenge: str | None = None, |
| 184 | + timeout: float | None = None, |
| 185 | + port: int | None = None, |
| 186 | + extra_scopes_to_consent: list[str] | None = None, |
| 187 | + max_age: int | None = None, |
| 188 | + parent_window_handle: object | None = None, |
| 189 | + on_before_launching_ui: _OnBeforeLaunchingUI | None = None, |
| 190 | + auth_scheme: PopAuthScheme | None = None, |
| 191 | + **kwargs: Any, |
| 192 | + ) -> dict[str, Any]: ... |
| 193 | + def initiate_device_flow( |
| 194 | + self, scopes: list[str] | None = None, *, claims_challenge: str | None = None, **kwargs: Any |
| 195 | + ) -> dict[str, Any]: ... |
| 196 | + def acquire_token_by_device_flow( |
| 197 | + self, flow: dict[str, Any], claims_challenge: str | None = None, **kwargs: Any |
| 198 | + ) -> dict[str, Any]: ... |
| 199 | + @deprecated( |
| 200 | + "This API has been deprecated for public client flows, please use a more secure flow. " |
| 201 | + "See https://aka.ms/msal-ropc-migration for migration guidance" |
| 202 | + ) |
| 203 | + def acquire_token_by_username_password( |
| 204 | + self, |
| 205 | + username: str, |
| 206 | + password: str, |
| 207 | + scopes: list[str], |
| 208 | + claims_challenge: str | None = None, |
| 209 | + auth_scheme: PopAuthScheme | None = None, |
| 210 | + **kwargs: Any, |
| 211 | + ) -> dict[str, Any]: ... |
| 212 | + |
| 213 | +class ConfidentialClientApplication(ClientApplication): |
| 214 | + def acquire_token_for_client( |
| 215 | + self, |
| 216 | + scopes: list[str], |
| 217 | + claims_challenge: str | None = None, |
| 218 | + fmi_path: str | None = None, |
| 219 | + forwarded_client_claims: str | None = None, |
| 220 | + **kwargs: Any, |
| 221 | + ) -> dict[str, Any]: ... |
| 222 | + def remove_tokens_for_client(self) -> None: ... |
| 223 | + def acquire_token_on_behalf_of( |
| 224 | + self, |
| 225 | + user_assertion: str, |
| 226 | + scopes: list[str], |
| 227 | + claims_challenge: str | None = None, |
| 228 | + forwarded_client_claims: str | None = None, |
| 229 | + **kwargs: Any, |
| 230 | + ) -> dict[str, Any]: ... |
| 231 | + def acquire_token_by_user_federated_identity_credential( |
| 232 | + self, |
| 233 | + scopes: list[str], |
| 234 | + assertion: str, |
| 235 | + username: str | None = None, |
| 236 | + user_object_id: str | None = None, |
| 237 | + claims_challenge: str | None = None, |
| 238 | + forwarded_client_claims: str | None = None, |
| 239 | + **kwargs: Any, |
| 240 | + ) -> dict[str, Any]: ... |
0 commit comments