Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sdk/identity/azure-identity/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Release History

## 1.4.0b5 (Unreleased)
## 1.4.0b5 (2020-06-12)
- Prevent an error on importing `AzureCliCredential` on Windows caused by a bug
in old versions of Python 3.6 (this bug was fixed in Python 3.6.5).
([#12014](https://github.com/Azure/azure-sdk-for-python/issues/12014))
- `SharedTokenCacheCredential.get_token` raises `ValueError` instead of
`ClientAuthenticationError` when called with no scopes.
([#11553](https://github.com/Azure/azure-sdk-for-python/issues/11553))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
COMMAND_LINE = "az account get-access-token --output json --resource {}"
NOT_LOGGED_IN = "Please run 'az login' to set up an account"

# CLI's "expiresOn" is naive, so we use this naive datetime for the epoch to calculate expires_on in UTC
EPOCH = datetime.fromtimestamp(0)


class AzureCliCredential(object):
"""Authenticates by requesting a token from the Azure CLI.
Expand Down Expand Up @@ -74,8 +71,8 @@ def parse_token(output):
token = json.loads(output)
parsed_expires_on = datetime.strptime(token["expiresOn"], "%Y-%m-%d %H:%M:%S.%f")

# calculate seconds since the epoch; parsed_expires_on and EPOCH are naive
expires_on = (parsed_expires_on - EPOCH).total_seconds()
# calculate seconds since the epoch; parsed_expires_on is naive
expires_on = (parsed_expires_on - datetime.fromtimestamp(0)).total_seconds()

return AccessToken(token["accessToken"], int(expires_on))
except (KeyError, ValueError):
Expand Down