Skip to content

Potential mismatch between docstring and implementation of token_expiration_datetime #1186

@MartinM24

Description

@MartinM24

In the docstring for the method token_expiration_datetime it says that the expiration is extended by 3 months if the refresh token is present. As far as I can see, the method do not do this:

def token_expiration_datetime(
self, *, username: Optional[str] = None
) -> Optional[dt.datetime]:
"""
Returns the current access token expiration datetime
If the refresh token is present, then the expiration datetime is extended by 3 months
:param str username: The username from which check the tokens
:return dt.datetime or None: The expiration datetime
"""
access_token = self.get_access_token(username=username)
if access_token is None:
return None
expires_on = access_token.get("expires_on")
if expires_on is None:
# consider the token has expired
return None
else:
expires_on = int(expires_on)
return dt.datetime.fromtimestamp(expires_on)

Earlier the code did extend it

expires_on = access_expires_at - dt.timedelta(seconds=EXPIRES_ON_THRESHOLD)
if self.is_long_lived:
expires_on = expires_on + dt.timedelta(days=90)
return expires_on

Is the current method correct, or am I misunderstanding how it works?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions