Skip to content

Commit

Permalink
[Identity] Stop using deprecated datetime methods (#36952)
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Van Eck <[email protected]>
  • Loading branch information
pvaneck committed Aug 20, 2024
1 parent 50f0fa2 commit 347c625
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from datetime import datetime
from datetime import datetime, timezone
import time
from typing import Dict, Optional, Callable, Any

Expand Down Expand Up @@ -93,10 +93,9 @@ def _request_token(self, *scopes: str, **kwargs: Any) -> Dict:
raise ClientAuthenticationError(
message="Couldn't begin authentication: {}".format(flow.get("error_description") or flow.get("error"))
)

if self._prompt_callback:
self._prompt_callback(
flow["verification_uri"], flow["user_code"], datetime.utcfromtimestamp(flow["expires_at"])
flow["verification_uri"], flow["user_code"], datetime.fromtimestamp(flow["expires_at"], timezone.utc)
)
else:
print(flow["message"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def test_device_code_credential():
disable_instance_discovery=True,
)

now = datetime.datetime.utcnow()
now = datetime.datetime.now(datetime.timezone.utc)
token = credential.get_token("scope")
assert token.token == expected_token

Expand Down Expand Up @@ -269,7 +269,6 @@ def test_tenant_id():
additionally_allowed_tenants=["*"],
)

now = datetime.datetime.utcnow()
token = credential.get_token("scope", tenant_id="tenant_id")
assert token.token == expected_token

Expand Down

0 comments on commit 347c625

Please sign in to comment.