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

Fix: Signature compatibility #368

Merged
merged 1 commit into from
Dec 11, 2024
Merged
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
Fix: Signature compatibility
  • Loading branch information
alzheltkovskiy-hubspot committed Dec 11, 2024
commit 0495a4cfda6fd1dfaca13d4cd123651acbd8b336
6 changes: 3 additions & 3 deletions hubspot/utils/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import hmac
import hashlib

from datetime import datetime, UTC, timedelta
from datetime import datetime, timezone, timedelta

from hubspot.exceptions import InvalidSignatureVersionError, InvalidSignatureTimestampError

Expand All @@ -16,8 +16,8 @@ def _is_timestamp_valid(timestamp: str) -> bool:
return False
try:
timestamp_float = float(timestamp)
request_time = datetime.fromtimestamp(timestamp_float // 1000, tz=UTC)
current_time = datetime.now(UTC)
request_time = datetime.fromtimestamp(timestamp_float // 1000, tz=timezone.utc)
current_time = datetime.now(timezone.utc)
return current_time - request_time < timedelta(seconds=Signature.MAX_ALLOWED_TIMESTAMP)
except (ValueError, OverflowError):
return False
Expand Down
Loading