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

ManagedIdentityCredential.get_token failed: 'int' object has no attribute 'endswith' #15361

Closed
yikei opened this issue Nov 17, 2020 · 2 comments · Fixed by #16536
Closed

ManagedIdentityCredential.get_token failed: 'int' object has no attribute 'endswith' #15361

yikei opened this issue Nov 17, 2020 · 2 comments · Fixed by #16536
Assignees
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. feature-request This issue requires a new behavior in the product in order be resolved.
Milestone

Comments

@yikei
Copy link

yikei commented Nov 17, 2020

  • Package Name: azure-identity
  • Package Version: 1.5.0
  • Operating System: Linux (Azure VM Standard_D11_v2)
  • Python Version: 3.6.8

Describe the bug
ManagedIdentityCredential.get_token fails using azure-identity 1.5.0.

To Reproduce
Running this script in an AzureML experiment:

from azure.identity import ManagedIdentityCredential
credential = ManagedIdentityCredential(client_id='REDACTED')
scope = 'https://storage.azure.com/.default'
access_token = credential.get_token(scope)
print(access_token)

Yields this error:

Traceback (most recent call last):
  File "azid.py", line 4, in <module>
    access_token = credential.get_token(scope)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_internal/decorators.py", line 27, in wrapper
    token = fn(*args, **kwargs)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_credentials/managed_identity.py", line 93, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_credentials/app_service.py", line 38, in get_token
    return super(AppServiceCredential, self).get_token(*scopes, **kwargs)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_internal/get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_credentials/app_service.py", line 46, in _request_token
    return self._client.request_token(*scopes, **kwargs)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_internal/managed_identity_client.py", line 73, in request_token
    token = self._process_response(response, request_time)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_internal/managed_identity_client.py", line 91, in _process_response
    self._content_callback(content)
  File "/azureml-envs/azureml_058b99fb4f93bed0f3577d17fc03a78e/lib/python3.6/site-packages/azure/identity/_credentials/app_service.py", line 93, in _parse_app_service_expires_on
    if expires_on.endswith(" +00:00"):
AttributeError: 'int' object has no attribute 'endswith'

Expected behavior
Access token retrieved.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@ghost ghost added the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Nov 17, 2020
@chlowell chlowell self-assigned this Nov 17, 2020
@chlowell chlowell added Azure.Identity Client This issue points to a problem in the data-plane of the library. and removed needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Nov 17, 2020
@chlowell
Copy link
Member

Thanks for reporting this! It's the first I've heard of Azure ML managed identity. It happens that Azure ML's managed identity implementation closely resembles App Service's but doesn't behave the same. We'll have to do some work to support it. I'll put this on the backlog while I figure out where it fits into our release schedule.

@chlowell chlowell added the feature-request This issue requires a new behavior in the product in order be resolved. label Nov 17, 2020
@chlowell chlowell added this to the Backlog milestone Nov 17, 2020
@yikei
Copy link
Author

yikei commented Nov 17, 2020

Thank you, Charles! As a mitigation, we have set our dependency of azure-identity to <1.5.0. Once this issue is resolved we will remove the upper bound.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity Client This issue points to a problem in the data-plane of the library. feature-request This issue requires a new behavior in the product in order be resolved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants