azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

'ClientSecretCredential' object has no attribute 'signed_session'

Open spoloj opened this issue 5 years ago • 2 comments

  • Package Name: azure-identity
  • Package Version: 1.5.0
  • Package Name: azure-mgmt-managementgroups
  • Package Version: 0.2.0
  • Operating System: linux
  • Python Version: 3.8.5

Describe the bug

from azure.identity import ClientSecretCredential
import azure.mgmt.managementgroups

azure_credential = ClientSecretCredential(
    client_id=xxxxxxx,
    client_secret=xxxxxx,
    tenant_id=xxxxx)

management_client = azure.mgmt.managementgroups.ManagementGroupsAPI(azure_credential)
mgmt_groups = management_client.management_groups.get(
    "test",
    expand='children'
)
subs = []
for record in mgmt_groups.children:
    subs.append(record.name)

This is giving an error AttributeError: 'ClientSecretCredential' object has no attribute 'signed_session'

Additional context Authentication with ClientSecretCredential to resources library and subscription library is working but not to Management Groups

spoloj avatar Feb 04 '21 02:02 spoloj

Edit: azure-mgmt-managementgroups 1.0.0 is available now, with support for azure-identity credentials. I recommend ugprading to that version. My suggestions below apply only to lower versions of azure-mgmt-managementgroups.

The latest version of ManagementGroupsAPI doesn't support credentials from azure-identity (a future version might, @msyyc for any comment on the roadmap). It expects an msrestazure authentication class. There are a couple ways you can move forward:

  1. Use msrestazure.azure_active_directory.ServicePrincipalCredentials instead of ClientSecretCredential
  2. Use AzureIdentityCredentialWrapper to wrap ClientSecretCredential

AzureIdentityCredentialWrapper is convenient if your application also uses clients expecting azure-identity credentials. If your application uses only ManagementGroupsAPI, or uses only clients expecting the msrestazure API, I'd suggest using ServicePrincipalCredentials.

(Related: #9756, #10274, #14499, #15330)

chlowell avatar Feb 04 '21 16:02 chlowell

Close this as it's duplicated with https://github.com/Azure/azure-sdk-for-python/issues/16923

jsntcy avatar Apr 13 '21 07:04 jsntcy