Get ACR token from ContainerRegistryClient
Is your feature request related to a problem? Please describe. When you want to get an ACR refresh token like you would with
az acr login --name <acrName> --expose-token --output tsv --query accessToken
using the Python SDK, there is no easy way to do it. Logic is buried in the ACRExchangeClient class which is not supposed to be used directly.
Describe the solution you'd like
A method directly available on the ContainerRegistryClient class to get the ACR token that can then be used for docker login command.
Describe alternatives you've considered
I considered hack around the ACRExchangeClient and ContainerRegistryChallengePolicy classes but that just doesn't feel right.
Additional context Similar feature request has been made on the JS SDK
Thank you for your feedback. Tagging and routing to the team member best able to assist.
Hi @EppO , thanks for your contact!
You can get the access token through Azure CLI, or we'll handle access token seamlessly when you're using Azure SDK. Can you share more info about the situation that need to get access token from Azure SDK?
Hi @EppO. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
You can get the access token through Azure CLI, or we'll handle access token seamlessly when you're using Azure SDK. Can you share more info about the situation that need to get access token from Azure SDK?
Hi @YalinLi0312,
I didn't find a way to get the refresh token "seamlessly" with the SDK. My use case is to be able to authenticate against the ACR like in the following scenario with az CLI:
$ ACCESS_TOKEN=$(az acr login --name MyACR --expose-token --output tsv --query accessToken)
$ az acr repository list -n MyACR --username 00000000-0000-0000-0000-000000000000 --password "$ACCESS_TOKEN"
How can you get the ACCESS_TOKEN using the SDK?
This is important in order to be able to disable admin user access keys on the ACR to improve the security posture and still have the capability to list the repositories in the ACR with the user or script's managed Id permissions.
@YalinLi0312: Can you please describe a way to get the refresh token seamlessly using the SDK? I would second @sgerace's comment in Azure JS SDK about the same matter but for the python SDK counterpart
I think the existence of az acr login --expose-token is a good indication that the ability to get a refresh token is a generally useful function, so it seems reasonable to me that automating this task via some JavaScript tooling would also be useful to support (by exposing a function that performs a similar task).
Hi @EppO, we deeply appreciate your input into this project. Regrettably, this issue has remained unresolved for over 2 years and inactive for 30 days, leading us to the decision to close it. We've implemented this policy to maintain the relevance of our issue queue and facilitate easier navigation for new contributors. If you still believe this topic requires attention, please feel free to create a new issue, referencing this one. Thank you for your understanding and ongoing support.