'Verify the token is valid format and has not expired.'

def _is_valid_token(self, token, window_seconds=0):

    current_time = timeutils.normalize_time(timeutils.utcnow())
    try:
        token_data = token.get('token', token.get('access'))
        expires_at = token_data.get('expires_at', token_data.get('expires'))
        if (not expires_at):
            expires_at = token_data['token']['expires']
        expiry = timeutils.parse_isotime(expires_at)
        expiry = timeutils.normalize_time(expiry)
        expiry += datetime.timedelta(seconds=window_seconds)
    except Exception:
        LOG.exception('Unexpected    error    or    malformed    token    determining    token    expiry:    %s', token)
        raise exception.TokenNotFound(_('Failed    to    validate    token'))
    if (current_time < expiry):
        self.check_revocation(token)
        return None
    else:
        raise exception.TokenNotFound(_('Failed    to    validate    token'))
