Skip to content

Invalid type for expiry when using GCE metadata server #479

@danxmoran

Description

@danxmoran

Environment details

  • OS: Linux
  • Python version: 3.8.2
  • pip version: 20.0.2
  • google-auth version: 1.12.0

Steps to reproduce

  1. Create an ID token using the GCE metadata server:
    from google.auth import compute_engine
    import google.auth.transport.requests
    request = google.auth.transport.requests.Request()
    target_audience = 'https://example.com'
    creds = compute_engine.IDTokenCredentials(request, target_audience, use_metadata_identity_endpoint=True)
  2. Try to use the credentials to authorize a request:
    from google.auth.transport.requests import AuthorizedSession
    session = AuthorizedSession(credentials)
    response = session.get('https://example.com')

This results in an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/google/auth/credentials.py", line 66, in expired
    skewed_expiry = self.expiry - _helpers.CLOCK_SKEW
TypeError: unsupported operand type(s) for -: 'int' and 'datetime.timedelta'

I think the issue is on this line. payload["exp"] should (apparently) be getting parsed into a datetime.timedelta

Metadata

Metadata

Labels

🚨This issue needs some love.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions