Skip to content

ClientAssertionCredential constructor fails if kwargs are provided #33673

@ppaglilla

Description

@ppaglilla
  • Package Name: azure-identity
  • Package Version: 1.15.0
  • Operating System: Linux 6.1.58+ x86_64 GNU/Linux
  • Python Version: 3.11.5 and 3.9.2

Describe the bug
The ClientAssertionCredential constructor accepts the authority and additionally_allowed_tenants arguments through kwargs. However, if any of those arguments are provided, they are incorrectly bubbled up through a super().init(**kwargs) call to GetTokenMixin and abc.ABC. That ultimately makes construction fail with:

super(GetTokenMixin, self).__init__(*args, **kwargs)  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object.__init__() takes exactly one argument (the instance to initialize)

To Reproduce

from typing import Callable
from azure.identity import ClientAssertionCredential

tenant_id: str= "TENANT_ID"
client_id: str= "CLIENT_ID"
func: Callable[[], str] = lambda: "TOKEN"

credential: ClientAssertionCredential = ClientAssertionCredential(
    tenant_id=tenant_id,
    client_id=client_id,
    func=func,
    additionally_allowed_tenants=[])

Expected behavior
The ClientAssertionCredential object is built successfully.

Additional context
I'm currently working around this by forcefully inspecting the credential object and injecting the settings as needed.

credential: ClientAssertionCredential = ClientAssertionCredential(
    tenant_id=tenant_id,
    client_id=client_id,
    func=func)

credential._client._additionally_allowed_tenants = []

Metadata

Metadata

Assignees

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.customer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions