Skip to content

Commit

Permalink
Merge pull request #368 from HubSpot/fix/signature-compatibility
Browse files Browse the repository at this point in the history
Fix: Signature compatibility
  • Loading branch information
alzheltkovskiy-hubspot authored Dec 11, 2024
2 parents ae05323 + 0495a4c commit d7c7dce
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit d7c7dce

Please sign in to comment.