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

[BUG] AzureCliCredential improperly parses expiresOn returned from 'az account get-access-token' #15801

Closed
schaabs opened this issue Oct 8, 2020 · 0 comments · Fixed by #16559
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.

Comments

@schaabs
Copy link
Member

schaabs commented Oct 8, 2020

The the value of the "expiresOn" feild returned from az account get-access-token is a local time with no timezone information, for example "2020-10-07 09:53:24.773201". However, when we parse we use the AdjustToUniversal date time style

: DateTimeOffset.ParseExact(root.GetProperty("expiresOn").GetString(), "yyyy-MM-dd HH:mm:ss.ffffff", CultureInfo.InvariantCulture, DateTimeStyles.AdjustToUniversal);

According to the documentation AdjustToUniversal will result in a DateTimeOffset with Kind == Unspecified if no timezone is included in the string unless the AssumeLocal flag is also specified, so it can be adjusted to UTC.

Date and time are returned as a Coordinated Universal Time (UTC). If the input string denotes a local time, through a time zone specifier or AssumeLocal, the date and time are converted from the local time to UTC. If the input string denotes a UTC time, through a time zone specifier or AssumeUniversal, no conversion occurs. If the input string does not denote a local or UTC time, no conversion occurs and the resulting Kind property is Unspecified. This value cannot be used with RoundtripKind.

The code should be updated to pass both flags DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal.

@schaabs schaabs added Client This issue points to a problem in the data-plane of the library. Azure.Identity bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Oct 8, 2020
@schaabs schaabs added this to the [2020] November milestone Oct 8, 2020
@schaabs schaabs self-assigned this Oct 8, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Mar 28, 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant