AttributeError: 'UserPassCredentials' object has no attribute 'get_token'
See original GitHub issueimport os
from msrestazure.azure_active_directory import UserPassCredentials
from azure.mgmt.resource import ResourceManagementClient
credentials = UserPassCredentials(username=os.getenv('AZURE_USERNAME'), password=os.getenv('AZURE_PASSWORD'))
subscription_id = os.getenv('AZURE_SUBSCRIPTION')
resource_client = ResourceManagementClient(credentials, subscription_id)
resource_list = resource_client.resource_groups.list()
for resource in resource_list:
print(resource)
For the above code I am running into the error -
AttributeError: ‘UserPassCredentials’ object has no attribute ‘get_token’
I have to use Active directory to authenticate. I have the token embedded inside the credentials. I think I am missing something here. Can you please guide me in the right direction on how can I list all the resource group in my subscriptions using the credentials that I generated or if I need to use a different method.
Update 1 - Fixed a typo
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
'ServicePrincipalCredentials' object has no attribute 'get_token'
Run pip install azure-identity to get the package. References: Azure SDK for Python on GitHub.
Read more >Why am I getting AttributeError: Object has no attribute?
PYTHON : Why am I getting AttributeError : Object has no attribute ? [ Gift : Animated Search Engine ...
Read more >AttributeError: 'Token' object has no attribute 'test' solved
This video will help to solve attribute error while rendering templates in flask...
Read more >AttributeError: 'int' object has no attribute 'split' - YouTube
fixed attributeerror : 'int' object has no attribute 'split'thanks for watching! subscribe(); to support 00110110 thank you ...
Read more >msrestazure.azure_active_directory.UserPassCredentials class
Credentials object for Headless Authentication, i.e. AAD authentication via username and password. Headless Auth requires an AAD login (no a Live ID) that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Ah, I see, the issue then is azure-mgmt-subscription’s SubscriptionClient, which expects an msrestazure credential. I’m not so familiar with these libraries, but I see there’s a
azure.mgmt.resource.subscriptions.SubscriptionClientthat might be all you need to list subscriptions. If you must use azure-mgmt-subscription and want to use the same credential object with ResourceManagementClient and SubscriptionClient, you could use AzureIdentityCredentialWrapper. It wraps an msrestazure credential with the azure-identity API, allowing you to usemsrestazure.azure_active_directory.UserPassCredentialswith ResourceManagementClient.@changlong-liu what’s the story with azure-mgmt-subscription? Will it have a track 2 version?
Hi, we’re sending this friendly reminder because we haven’t heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don’t hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!