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

DefaultAzureCredentials.get_token invalid response after using az login #37841

Open
mmicek opened this issue Oct 10, 2024 · 5 comments
Open

DefaultAzureCredentials.get_token invalid response after using az login #37841

mmicek opened this issue Oct 10, 2024 · 5 comments
Assignees
Labels
Azure.Identity customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@mmicek
Copy link

mmicek commented Oct 10, 2024

azure-identity = "^1.19.0"
Ubuntu 20
Python 3.11

I am using DefaultAzureCredentials and i want to use AzureCliCredential. I would like to call get_token() method for BlobStorage and get token for logged user.

This is my very simple code:

credential = AzureCliCredential() token = credential.get_token("https://storage.azure.com/.default") print(token.token)

Before that i am using az login in terminal inside python environment, and i am succesfully logged in.

In azure.identity._credentials.azure_cli.parse_token method i am getting exception due to invalid json.
Azure can see me be logged into, and returns access_token and other stuff but adds some additional
invalid signs at the end of string so it makes string invalid json.

Image

How to get AzureCliCredential working properly?

Exception:
  AzureCliCredential: Unexpected output from Azure CLI: '{ ****, "expiresOn": "2024-10-10 19:23:33.461197", "subscription": "proper_value_here", "tenant": "proper_value_here", "tokenType": "Bearer" } '. To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/azclicredential/troubleshoot.

@github-actions github-actions bot added customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Oct 10, 2024
@github-actions github-actions bot removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Oct 10, 2024
@pvaneck pvaneck self-assigned this Oct 10, 2024
@pvaneck
Copy link
Member

pvaneck commented Oct 10, 2024

This appears to be some edge case dealing with console colorization when running code directly in PyCharm as described here: tartley/colorama#263

This was supposedly fixed for AzureCliCredential in this PR a while back.

Can you run az --version in the terminal you are using and paste the contents? I am wondering if this could be mitigated by just updated az.

@mmicek
Copy link
Author

mmicek commented Oct 11, 2024

azure-cli 2.0.81

core 2.0.81
telemetry 1.0.4

Python location /usr/bin/python3
Extensions directory '/home/adn/.azure/cliextensions'

Python (Linux) 3.8.10 (default, Sep 11 2024, 16:02:53)
[GCC 9.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Unable to check if your CLI is up-to-date. Check your internet connection.
Please let us know how we are doing: https://aka.ms/clihats`

@mmicek
Copy link
Author

mmicek commented Oct 11, 2024

I have some old version of this library, and i tried to update it but why newest version of azure-cli depends on some old azure-mgn-containerapp library?

Because azure-cli (2.65.0) depends on azure-mgmt-appcontainers (2.0.0) and no versions of azure-cli match >2.65.0,<3.0.0, azure-cli (>=2.65.0,<3.0.0) requires azure-mgmt-appcontainers (2.0.0). So, because epo-data-loader depends on both azure-mgmt-appcontainers (^3.0.0) and azure-cli (^2.65.0), version solving failed.

There is azure-mgmt-appcontainers version 3.1.0 why it needs 2.0.0??

@pvaneck
Copy link
Member

pvaneck commented Oct 11, 2024

Yep, looks it this is just a matter of the azure-cli version being too old.

azure-cli pins a lot of dependencies which might not work well with your application's dependencies if you installed azure-cli via pip/poetry. Typically, it's recommended to install the CLI using your OS distribution's package manager, as this will isolate the azure-cli dependencies. Check the instructions here.

@pvaneck pvaneck added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Oct 11, 2024
Copy link

Hi @mmicek. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text "/unresolve" to remove the "issue-addressed" label and continue the conversation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure.Identity customer-reported Issues that are reported by GitHub users external to the Azure organization. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
Status: Untriaged
Development

No branches or pull requests

2 participants