Skip to content

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

Closed

Description

@yikei
  • 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.

Activity

  1. ghost added
    needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.
    on Nov 17, 2020
  2. added
    ClientThis issue points to a problem in the data-plane of the library.
    and removed
    needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.
    on Nov 17, 2020
  3. chlowell commented on Nov 17, 2020

    @chlowell
    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.

  4. yikei commented on Nov 17, 2020

    @yikei
    Author

    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.

  5. locked and limited conversation to collaborators on Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.feature-requestThis issue requires a new behavior in the product in order be resolved.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions