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

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

Closed
sdebruyn opened this issue Nov 8, 2021 · 4 comments
Assignees
Labels
Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team

Comments

@sdebruyn
Copy link

sdebruyn commented Nov 8, 2021

  • 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"
}
@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 8, 2021
@sdebruyn
Copy link
Author

sdebruyn commented Nov 9, 2021

Source issue: Azure/azure-cli#20211
But maybe should be properly error handled here as well?

@xiangyan99 xiangyan99 added Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. and removed question The issue doesn't require a change to the product in order to be resolved. Most issues start as that needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. labels Nov 9, 2021
@ghost ghost added the needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team label Nov 9, 2021
@xiangyan99
Copy link
Member

@schaabs if expiresOn is null, should we give a default value? if yes, which one is suitable?

Thanks.

@xiangyan99
Copy link
Member

@jiasli please see Charles' comment #22899 (comment).

Any opinion?

@jiasli
Copy link
Member

jiasli commented Feb 9, 2022

This issue has long been fixed (Azure/azure-cli#20219). Azure CLI guarantees the existence of expiresOn.

azure-sdk pushed a commit to azure-sdk/azure-sdk-for-python that referenced this issue Feb 1, 2023
Machinelearningservices microsoft.machine learning services 2022 12 01 preview (Azure#21761)

* Adds base for updating Microsoft.MachineLearningServices from version preview/2022-10-01-preview to version 2022-12-01-preview

* Updates readme

* Updates API version in new specs and examples

* Add Dec API Registries Swagger (Azure#21419)

* add december registries swagger + examples

* add status code 202 in examples

* fix 202 examples

* fixes

* fixes

* fix

* add 202 back in for put/patch

Co-authored-by: Komal Yadav <komalyadav@microsoft.com>

* remove location (Azure#21430)

Co-authored-by: Komal Yadav <komalyadav@microsoft.com>

* remove readonly flag on schedules property for CI (Azure#21653)

Co-authored-by: Naman Agarwal <naagarw@microsoft.com>

* add missing workspace properties (Azure#21725)

* December preview updating mfe.json specs (Azure#21510)

* December preview updating mfe.json specs

* MFE Dec 2022 Preview API - Adding logbase

* MFE 2022-12-01-preview swagger spec model validation fix

* MFE 2022-12-01-preview swagger spec model validation fix, add missing location

* MFE 2022-12-01-preview swagger spec model validation - typo fix

* MFE 2022-12-01-preview swagger spec model validation - fix api version in automljob example

* MFE 2022-12-01-preview swagger spec model validation - fix for multiselectenabled error

* MFE 2022-12-01-preview swagger spec model validation - fix for multiselectenabled error

* Fix  for 1006 - RemovedDefinition (RecurrenceTrigger,CronTrigger) (Azure#21822)

* fix ReadonlyPropertyChanged of MLC (Azure#21814)

Co-authored-by: Bingchen Li <bingchenli@microsoft.com>

* fixed custom-words conflict (Azure#21829)

* fix custom-words conflict merge (Azure#21830)

* example fix (INVALID_REQUEST_PARAMETER) (Azure#21832)

Co-authored-by: Ivaliy Ivanov <ivaliyivanov@Ivaliys-MacBook-Air.local>

* example fix, use correct api preview version  - (INVALID_REQUEST_PARAMETER) (Azure#21833)

Co-authored-by: Ivaliy Ivanov <ivaliyivanov@Ivaliys-MacBook-Air.local>

* Revert breaking change for MLC swagger 2022-12-01-preview (Azure#21885)

Co-authored-by: Bingchen Li <bingchenli@microsoft.com>

* Revert Connection Category back to enum. (Azure#21939)

* revert provisioning state change (Azure#21940)

* remove body (Azure#21978)

Co-authored-by: Komal Yadav <komalyadav@microsoft.com>

* Addressed comments, added x-ms-long-running-operation to a patch call (Azure#22005)

* Addressed comments, added x-ms-long-running-operation to a patch call

* fix examples for patch - remove body

* fixed formatting

* Ivalbert fix patch2 (Azure#22006)

* Addressed comments, added x-ms-long-running-operation to a patch call

* fix examples for patch - remove body

* fixed formatting

* fixed formatting

* Updated custom words (Azure#22262)

* Fixed prettier errors (Azure#22237)

* fixed examples for LRO_RESPONSE_HEADER check (Azure#22293)

* fixed examples for LRO_RESPONSE_HEADER check (Azure#22294)

* Example fix - OBJECT_MISSING_REQUIRED_PROPERTY - Missing required property: triggerType (Azure#22317)

---------

Co-authored-by: Komal Yadav <23komal.yadav23@gmail.com>
Co-authored-by: Komal Yadav <komalyadav@microsoft.com>
Co-authored-by: Naman Agarwal <namanag16@gmail.com>
Co-authored-by: Naman Agarwal <naagarw@microsoft.com>
Co-authored-by: ZhidaLiu <zhili@microsoft.com>
Co-authored-by: libc16 <88697960+libc16@users.noreply.github.com>
Co-authored-by: Bingchen Li <bingchenli@microsoft.com>
Co-authored-by: Ivaliy Ivanov <ivaliyivanov@Ivaliys-MacBook-Air.local>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. needs-team-attention Workflow: This issue needs attention from Azure service team or SDK team
Projects
None yet
Development

No branches or pull requests

4 participants