Skip to content

Commit

Permalink
Add property expiry in gspread client
Browse files Browse the repository at this point in the history
In gspread client add a new property expiry which returns the expiry
datetime object from the used credentials.

The expiry only exists for OAuth credentials otherwise it returns None.

closes #1169

Signed-off-by: Alexandre Lavigne <[email protected]>
  • Loading branch information
lavigne958 committed Apr 16, 2024
1 parent fb065dc commit 5c63b39
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gspread/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""

from datetime import datetime
from http import HTTPStatus
from typing import Any, Dict, List, Optional, Tuple, Union

Expand Down Expand Up @@ -39,6 +40,18 @@ def __init__(
) -> None:
self.http_client = http_client(auth, session)

@property
def expiry(self) -> Optional[datetime]:
"""Returns the expiry date of the curenlty loaded credentials
:returns: (optional) datetime the expiry date time object.
.. note::
It only applies to gspread client created using oauth
"""
return self.http_client.auth.expiry

def set_timeout(
self, timeout: Optional[Union[float, Tuple[float, float]]] = None
) -> None:
Expand Down

0 comments on commit 5c63b39

Please sign in to comment.