Skip to content

AzureCliCredential fails to get token because strptime() argument 1 must be str, not None #21653

@sdebruyn

Description

@sdebruyn
  • Package Name: azure-identity
  • Package Version: 1.7.0
  • Operating System: Linux-5.4.0-1059-azure-x86_64-with-glibc2.28 (Debian slim Buster)
  • Python Version: 3.9.7

Bug description
AzureCliCredential fails to get token. Scope was "https://database.windows.net//.default"

[2021-11-09 00:08:54,452] {subprocess.py:78} INFO - 2021-11-08 23:08:54.451818 (MainThread): AzureCliCredential.get_token failed: strptime() argument 1 must be str, not None
[2021-11-09 00:08:54,452] {subprocess.py:78} INFO - Traceback (most recent call last):
[2021-11-09 00:08:54,452] {subprocess.py:78} INFO -   File "/home/airflow/.local/lib/python3.9/site-packages/azure/identity/_internal/decorators.py", line 30, in wrapper
[2021-11-09 00:08:54,452] {subprocess.py:78} INFO -     token = fn(*args, **kwargs)
[2021-11-09 00:08:54,452] {subprocess.py:78} INFO -   File "/home/airflow/.local/lib/python3.9/site-packages/azure/identity/_credentials/azure_cli.py", line 75, in get_token
[2021-11-09 00:08:54,453] {subprocess.py:78} INFO -     token = parse_token(output)
[2021-11-09 00:08:54,453] {subprocess.py:78} INFO -   File "/home/airflow/.local/lib/python3.9/site-packages/azure/identity/_credentials/azure_cli.py", line 94, in parse_token
[2021-11-09 00:08:54,453] {subprocess.py:78} INFO -     dt = datetime.strptime(token["expiresOn"], "%Y-%m-%d %H:%M:%S.%f")
[2021-11-09 00:08:54,453] {subprocess.py:78} INFO - TypeError: strptime() argument 1 must be str, not None

Context
Azure CLI is logged in using MSI

Command: az login -i
Output:

[2021-11-09 00:08:47,407] {subprocess.py:74} INFO - Output:
[2021-11-09 00:08:48,852] {subprocess.py:78} INFO - [
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -   {
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "environmentName": "AzureCloud",
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "homeTenantId": "xxx",
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "id": "xxx",
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "isDefault": true,
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "managedByTenants": [
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -       {
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -         "tenantId": "xxx"
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -       }
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     ],
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "name": "xxx",
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "state": "Enabled",
[2021-11-09 00:08:48,853] {subprocess.py:78} INFO -     "tenantId": "xxx",
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO -     "user": {
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO -       "assignedIdentityInfo": "MSI",
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO -       "name": "systemAssignedIdentity",
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO -       "type": "servicePrincipal"
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO -     }
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO -   }
[2021-11-09 00:08:48,854] {subprocess.py:78} INFO - ]

When I use az account get-access-token --resource https://database.windows.net/ I get null for the expiresOn:

{
  "accessToken": "ey...",
  "expiresOn": null,
  "subscription": "xxx",
  "tenant": "xxx",
  "tokenType": "Bearer"
}

Metadata

Metadata

Labels

Azure.IdentityClientThis issue points to a problem in the data-plane of the library.bugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions