Gets a stored token and returns a boolean of whether it was valid.
180930
function hasValidToken (storageLocation) {
	var token = getStoredToken(storageLocation);
	if (token) {
		try {
			var payload = decode(token);
			return payloadIsValid(payload);
		} catch (error) {
			return false;
		}
	}
	return false;
}
877849
def get_token(self):
        
        if self.token == None:
            self.token = self.authenticate(self.username, self.password)
        try:
            return str(self.token,'utf-8')
        except TypeError:
            return self.token
57163
def valid(cls, token, **kwargs):
        
        try:
            token = yield cls.get(token)
        except couch.NotFound:
            raise Return(False)

        raise Return(token.ttl >= datetime.utcnow())
723290
public function validateToken() {
        $userData = $this->_store->userData;
        $currToken = $this->_store->token;
        $checkToken = $this->createToken(serialize($userData));
        return $checkToken === $currToken;
    }
576130
static String getSQL(Token[] statement) {

        boolean      wasDelimiter = true;
        StringBuffer sb           = new StringBuffer();

        for (int i = 0; i < statement.length; i++) {
            // when the previous statement is ')', there should be a blank before the non-delimiter statement.
            if (!statement[i].isDelimiter &&
                    (!wasDelimiter
                            || (i > 0 && ")".equals(statement[i - 1].getSQL()))))
            {
                sb.append(' ');
            }

            sb.append(statement[i].getSQL());

            wasDelimiter = statement[i].isDelimiter;
        }

        return sb.toString();
    }
683913
async def valid_token_set(self):
        """"""
        is_valid = False

        if self._auth_client.token:
            # Account for a token near expiration
            now = datetime.datetime.utcnow()
            skew = datetime.timedelta(seconds=60)
            if self._auth_client.expiry > (now + skew):
                is_valid = True
        return is_valid
639091
function(tokenStr) {
            if (typeof tokenStr !== 'string') {
                return null;
            }
            var token = tokenCache[tokenStr];
            if (token !== undefined) {
                return token;
            } else {
                try {
                    token = tokens.validate(tokenStr, trustedPubKey);
                    tokenCache[tokenStr] = token;
                    return token;
                } catch (err) {
                    // did not validate, cache negative result.
                    tokenCache[tokenStr] = null;
                    return null;
                }
            }
        }
6298
public static function isTokenValid(string $token): bool
    {
        if (!static::hasTokenStored()) {
            return false;
        }

        $storedToken = static::getStoredToken();
        return $storedToken->getToken() === $token;
    }
465587
def get(self, username):
        
        if not self.remember:
            raise NotSaving

        if username not in self.token_storage:
            raise UserNotFound

        if self.token_storage[username]['expiration'] < time.time():
            new_token = self.refresh(self.token_storage[username]['refresh'])
            self.token_storage[username]['token'] = new_token[0]
            self.token_storage[username]['expiration'] = new_token[1]
            return new_token[0]
        else:
            return self.token_storage[username]['token']
680230
def _verify_token(self):
        
        res = self._session.get(self._token_verification_url)
        if not res.ok:
            raise exceptions.BadToken(consts.LOG_MSG_BAD_TOKEN)
        return True
1163155
public boolean contain(OidcTokenImplBase token) { //(IdToken token) {

        String key = token.getJwtId();
        if (key == null) {
            return false;
        }
        key = getCacheKey(token);
        long currentTimeMilliseconds = (new Date()).getTime();
        synchronized (primaryTable) {
            Long exp = (Long) primaryTable.get(key); // milliseconds
            if (exp != null) {
                if (exp.longValue() > currentTimeMilliseconds) { // not expired yet // milliseconds
                    return true;
                } else {
                    primaryTable.remove(key);
                }
            }
            // cache the jwt
            long tokenExp = token.getExpirationTimeSeconds() * 1000; // milliseconds
            if (tokenExp == 0) { // in case it's not set, let's give it one hour
                tokenExp = currentTimeMilliseconds + 60 * 60 * 1000; // 1 hour
            }
            primaryTable.put(key, Long.valueOf(tokenExp));
        }

        return false;
    }
988809
def verify_token(self, token):
        '''
        
        '''
        try:
            result = self.resolver.get_token(token)
        except Exception as ex:
            raise EauthAuthenticationError(
                "Token validation failed with {0}.".format(repr(ex)))

        return result
574306
@GET
    @Path("/validate/{token}")
    @Produces(MediaType.APPLICATION_JSON)
    public Response validateAccount(@PathParam("token") String token) {
        try{
            if (authServerLogic.validateAccount(token)) {
                return Response.ok().build();
            } else {
                return Response.status(Status.NOT_FOUND).build();
            }
        }catch (ServerDAO.DAOException e) {
            return fromDAOExpection(e);
        }
    }
128332
public CheckTokenResponse checkToken(TokenRequest tokenInfo) throws ApiException {
        ApiResponse<CheckTokenResponse> resp = checkTokenWithHttpInfo(tokenInfo);
        return resp.getData();
    }
770196
public boolean isValidToken() {
        try {
//            Response response = wsBase.path(TEST_CONFIGS).request(MediaType.APPLICATION_JSON_TYPE).get();
//            return response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL;

            LoadZone zone = getLoadZone(LoadZone.AMAZON_US_ASHBURN.uid);
            return zone == LoadZone.AMAZON_US_ASHBURN;
        } catch (Exception e) {
            log.info("API token validation failed: " + e);
        }
        return false;
    }
406179
def verify_verify(self, id, token):
        """"""
        return Verify().load(self.request('verify/' + str(id), params={'token': token}))
68774
def get_validated_token(self, raw_token):
        
        messages = []
        for AuthToken in api_settings.AUTH_TOKEN_CLASSES:
            try:
                return AuthToken(raw_token)
            except TokenError as e:
                messages.append({'token_class': AuthToken.__name__,
                                 'token_type': AuthToken.token_type,
                                 'message': e.args[0]})

        raise InvalidToken({
            'detail': _('Given token not valid for any token type'),
            'messages': messages,
        })