Skip to content

Bug in detecting "expires" timestamp #1028

@sdc50

Description

@sdc50

In the expiration_timedelta method there is a bug when determining if the expires value from extra_data is a timestamp or a number of seconds since the auth_time:

https://github.com/python-social-auth/social-core/blob/master/social_core/storage.py#L73

            now = datetime.now(timezone.utc)

            # Detect if expires is a timestamp
            if expires > now.timestamp():

The logic here seems to be that if expires is a number greater than now.timestamp() (i.e. around 1740600285) then it must be a timestamp, and not the number of seconds since auth_time. However, when the access_token is actually expired, then by definition, expires is less than now.timestamp().

With the current logic, when the token is expired then it is not determined to be a timestamp and is treated like the number of seconds since auth_time, so it calculates the expiration_timedelta to around 20,000 days in the future rather than being in the past. It therefore, never tries to refresh the token since it never realizes that it's expired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions