Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Authorization Code client_secret kwarg usage #34862

Merged
merged 8 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,12 @@ def get_token(
``response`` attribute.
"""
# pylint:disable=useless-super-delegation
return super(AuthorizationCodeCredential, self).get_token(*scopes, claims=claims, tenant_id=tenant_id, **kwargs)
client_secret = (
kwargs.pop("client_secret", None) or self._client_secret
) # If secret not provided in method, use init secret
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved
return super(AuthorizationCodeCredential, self).get_token(
*scopes, claims=claims, tenant_id=tenant_id, client_secret=client_secret, **kwargs
xiangyan99 marked this conversation as resolved.
Show resolved Hide resolved
)

def _acquire_token_silently(self, *scopes: str, **kwargs) -> Optional[AccessToken]:
return self._client.get_cached_access_token(scopes, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ def _get_refresh_token_request(self, scopes: Iterable[str], refresh_token: str,
"client_id": self._client_id,
"client_info": 1, # request Microsoft Entra ID include home_account_id in its response
}
client_secret = kwargs.pop("client_secret", None)
if client_secret:
data["client_secret"] = client_secret

claims = _merge_claims_challenge_and_capabilities(
["CP1"] if kwargs.get("enable_cae") else [], kwargs.get("claims")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ async def get_token(
attribute gives a reason. Any error response from Microsoft Entra ID is available as the error's
``response`` attribute.
"""
return await super().get_token(*scopes, claims=claims, tenant_id=tenant_id, **kwargs)
client_secret = (
kwargs.pop("client_secret", None) or self._client_secret
) # If secret not provided in method, use init secret
return await super(AuthorizationCodeCredential, self).get_token(
*scopes, claims=claims, tenant_id=tenant_id, client_secret=client_secret, **kwargs
)

async def _acquire_token_silently(self, *scopes: str, **kwargs: Any) -> Optional[AccessToken]:
return self._client.get_cached_access_token(scopes, **kwargs)
Expand Down