From 833898fe6cc572f12a16f6844c16cf42cc78d738 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 23:09:16 +0000 Subject: [PATCH 1/3] Initial plan From de6a4b1b16d2230f3380863f2664a29842f99a72 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 23:24:03 +0000 Subject: [PATCH 2/3] Fix azure-identity pylint 4.0.4 warnings Co-authored-by: azure-sdk <53356347+azure-sdk@users.noreply.github.com> --- .../token_binding_transport_requests.py | 4 ++-- .../token_binding_transport_asyncio.py | 2 +- .../samples/custom_credentials.py | 24 +++++++++++++++---- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/sdk/identity/azure-identity/azure/identity/_internal/token_binding_transport_requests.py b/sdk/identity/azure-identity/azure/identity/_internal/token_binding_transport_requests.py index 19d15abae1d9..aec49ae1f825 100644 --- a/sdk/identity/azure-identity/azure/identity/_internal/token_binding_transport_requests.py +++ b/sdk/identity/azure-identity/azure/identity/_internal/token_binding_transport_requests.py @@ -8,8 +8,8 @@ import ssl from typing import Any, Optional -from requests.adapters import HTTPAdapter -from requests import Session +from requests.adapters import HTTPAdapter # pylint: disable=networking-import-outside-azure-core-transport +from requests import Session # pylint: disable=networking-import-outside-azure-core-transport from azure.core.pipeline.transport import ( # pylint: disable=non-abstract-transport-import, no-name-in-module RequestsTransport, ) diff --git a/sdk/identity/azure-identity/azure/identity/aio/_internal/token_binding_transport_asyncio.py b/sdk/identity/azure-identity/azure/identity/aio/_internal/token_binding_transport_asyncio.py index fa236c2e4d4f..6aa02259c7f9 100644 --- a/sdk/identity/azure-identity/azure/identity/aio/_internal/token_binding_transport_asyncio.py +++ b/sdk/identity/azure-identity/azure/identity/aio/_internal/token_binding_transport_asyncio.py @@ -7,7 +7,7 @@ """ from typing import Any, Optional -from requests import Session +from requests import Session # pylint: disable=networking-import-outside-azure-core-transport from azure.core.pipeline.transport import ( # pylint: disable=non-abstract-transport-import, no-name-in-module AsyncioRequestsTransport, ) diff --git a/sdk/identity/azure-identity/samples/custom_credentials.py b/sdk/identity/azure-identity/samples/custom_credentials.py index 6177a4dbf0a7..c2074d1350f8 100644 --- a/sdk/identity/azure-identity/samples/custom_credentials.py +++ b/sdk/identity/azure-identity/samples/custom_credentials.py @@ -7,9 +7,9 @@ import time from typing import Optional, Union +import msal from azure.core.credentials import AccessToken from azure.identity import AuthenticationRequiredError, AzureAuthorityHosts -import msal class StaticTokenCredential(object): @@ -30,7 +30,14 @@ def __init__(self, access_token: Union[str, AccessToken]) -> None: def get_token( self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ) -> AccessToken: - """get_token is the only method a credential must implement""" + """Get an access token for the requested scopes. + + :param str scopes: desired scopes for the access token. + :keyword str claims: additional claims required in the token request. + :keyword str tenant_id: optional tenant to include in the token request. + :return: An access token with the requested scopes. + :rtype: ~azure.core.credentials.AccessToken + """ return self._token @@ -46,13 +53,20 @@ def __init__(self, tenant_id: str, client_id: str) -> None: def get_token( self, *scopes: str, claims: Optional[str] = None, tenant_id: Optional[str] = None, **kwargs ) -> AccessToken: - """get_token is the only method a credential must implement""" + """Get an access token for the requested scopes. + + :param str scopes: desired scopes for the access token. + :keyword str claims: additional claims required in the token request. + :keyword str tenant_id: optional tenant to include in the token request. + :return: An access token with the requested scopes. + :rtype: ~azure.core.credentials.AccessToken + """ now = int(time.time()) result = self._app.acquire_token_interactive(list(scopes), claims=claims, tenant_id=tenant_id, **kwargs) try: return AccessToken(result["access_token"], now + int(result["expires_in"])) - except: + except Exception as ex: print("\nFailed to get a valid access token") - raise AuthenticationRequiredError(scopes) + raise AuthenticationRequiredError(scopes) from ex From acd28db1f55d23757510ded472ebc11652b884cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Jun 2026 23:25:26 +0000 Subject: [PATCH 3/3] Tidy azure-identity sample import grouping Co-authored-by: azure-sdk <53356347+azure-sdk@users.noreply.github.com> --- sdk/identity/azure-identity/samples/custom_credentials.py | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/identity/azure-identity/samples/custom_credentials.py b/sdk/identity/azure-identity/samples/custom_credentials.py index c2074d1350f8..4c6fcbae655e 100644 --- a/sdk/identity/azure-identity/samples/custom_credentials.py +++ b/sdk/identity/azure-identity/samples/custom_credentials.py @@ -8,6 +8,7 @@ from typing import Optional, Union import msal + from azure.core.credentials import AccessToken from azure.identity import AuthenticationRequiredError, AzureAuthorityHosts