Look at the tests for appengine and gce and their implementations of
_refresh() method.
The current implementations of how they get access tokens throw away the
expires_in information and thus token_expiry remains None.
Returning None instead of 0 (for the _expires_in() private method), when
there is no actual token_expiry, conveys additional information (ie, that
there was no token_expiry set).

Think of it this way: the fact that the token_expiry was not set, does not
mean the token has expired (which would be implied by expires_in being 0
seconds). For all practical purposes, the token may still be valid. We just
don't know.


On Tue, Jun 3, 2014 at 12:55 PM, Craig Citro <notifications@github.com>
wrote:

> In oauth2client/client.py:
>
> > @@ -625,6 +628,18 @@ def set_store(self, store):
> >      """
> >      self.store = store
> >
> > +  def _expires_in(self):
> > +    """Return the number of seconds until this token expires."""
> > +    if self.token_expiry:
> > +      now = datetime.datetime.utcnow()
> > +      if self.token_expiry > now:
> > +        time_delta = self.token_expiry - now
> > +        # TODO(orestica): return time_delta.total_seconds()
> > +        # once dropping support for Python 2.6
> > +        return time_delta.days * 86400 + time_delta.seconds
> > +      else:
>
> Let me ask the question a different way: is there ever a case where you
> want to distinguish between token_expiry == 0 and token_expiry is None?
> My suspicion is no; the only thing you'll ever hit are issues where someone
> thought they had an int and had None instead.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/google/oauth2client/pull/15/files#r13355525>.
>



-- 
Orest Bolohan

Software Engineer
Cloud/TI Identity and Access Management Services
Google Inc.
Mountain View, CA

(650) 214 3458
orest@google.com