Skip to content

Deprecation warning for function datetime.datetime.utcfromtimestamp() #1781

@AddisonDunn

Description

@AddisonDunn

Environment details

  • OS: linux
  • Python version: 3.12.3
  • pip version: 25.1.1
  • google-auth version: 2.40.3

Steps to reproduce

  1. Make google auth request and fetch token:
import google.auth.transport.requests
import google.oauth2.id_token
google_auth_request = google.auth.transport.requests.Request()
token = google.oauth2.id_token.fetch_id_token(google_auth_request, url)
  1. See output:
  /azp/_work/1/s/.venv/lib/python3.12/site-packages/google/oauth2/_client.py:417: DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, datetime.UTC).
    expiry = datetime.datetime.utcfromtimestamp(payload["exp"])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions