Add additional docstring for the OAuth2Credentials._expires_in() method,

explaining what values are returned when token_expiry is in the past or
None.
This commit is contained in:
Orest Bolohan
2014-06-03 15:36:17 -07:00
parent 4bcd15ed0e
commit 95830b0a52

View File

@@ -629,7 +629,14 @@ class OAuth2Credentials(Credentials):
self.store = store
def _expires_in(self):
"""Return the number of seconds until this token expires."""
"""Return the number of seconds until this token expires.
If token_expiry is in the past, this method will return 0, meaning the
token has already expired.
If token_expiry is None, this method will return None. Note that returning
0 in such a case would not be fair: the token may still be valid;
we just don't know anything about it.
"""
if self.token_expiry:
now = datetime.datetime.utcnow()
if self.token_expiry > now: