Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

expires_in appears to be a string when returned from the token server #1207

Closed

Description

@rfloydb

When we reach this line of code, we get "TypeError: unsupported type for timedelta seconds component: str"

return _helpers.utcnow() + datetime.timedelta(seconds=expires_in)

It would appear that the response from the token server has expires_in as a string:

Request:

https://securetoken.googleapis.com/v1/token?key=AI... 
{
  'grant_type': 
  'refresh_token', 
  'client_id': '76...', 
  'client_secret': '...', 
  'refresh_token': 'AO...'
}

Response:

{
  'access_token': 'ey...', 
  **'expires_in': '3600'**, 
  'token_type': 'Bearer', 
  'refresh_token': 'AO...', 
  'id_token': 'ey...', 
  'user_id': 'Xs...', 
  'project_id': '23...'
}

Seems this code should expect a string and not an integer.

Activity

  1. clundin25 commented on Jan 3, 2023

    @clundin25
    Contributor

    Thanks for the report @rfloydb ! We will investigate and report back

  2. added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Jan 3, 2023
  3. clundin25 commented on Jan 4, 2023

    @clundin25
    Contributor

    Hi @rfloydb can you provide some more details on what you are trying to accomplish? And perhaps some details about this workflow?

  4. rfloydb commented on Jan 4, 2023

    @rfloydb
    Author

    I am trying to refresh a token. Roughly this:

    import firebase_admin
    
    from firebase_admin import auth
    from google.auth.transport.requests import Request
    from google.oauth2.credentials import Credentials
    
    firebase_admin.initialize_app()
    
    (id_token, refresh_token) = tokens()
    (client_id, client_secret) = client_id_and_secret()
    creds = Credentials(
        id_token, 
        refresh_token, 
        client_id = client_id,
        client_secret = client_secret,
        token_uri = 'https://securetoken.googleapis.com/v1/token?key=AI...',
    )
    
    try:
        decoded_token = auth.verify_id_token(creds.id_token)
    except firebase_admin.auth.ExpiredIdTokenError:
        try:
            r = Request()
            creds.refresh(r)
    
  5. clundin25 commented on Jan 6, 2023

    @clundin25
    Contributor

    @rfloydb This will be fixed in the next release. That should happen either today or early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in 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