Check the session's tokens are still valid! token_fetch var is the function calling the token check in cases where the function is actually already fetching tokens!
484945
function CheckTokens(callback, token_fetch)
	{
		// build list of tokens we're missing
		var todo = [];

		// force token_fetch to an array
		token_fetch = [].concat(token_fetch);

		// make sure we're actually logged in first
		if (!auth_obj.auth_code)
		{
			Log("Need to login - no auth token found");
			todo.push({name: "Login", func: Login});
		}

		if (!auth_obj.expire_time || auth_obj.expire_time < new Date().getTime())
		{
			// token has expired! Fetch access_token again
			Log("Need to fetch access tokens - tokens expired");
			todo.push({name: "GetAccessToken", func: GetAccessToken});
		}
		else if (!auth_obj.access_token)
		{
			// we have no access token (?!)
			Log("Need to fetch access tokens - no token available");
			todo.push({name: "GetAccessToken", func: GetAccessToken});
		}

		if (!auth_obj.username || !auth_obj.region)
		{
			// missing player username/region
			Log("Need to fetch userdata - no region or username available");
			todo.push({name: "GetUserData", func: GetUserData});
		}

		if (todo.length == 0)
		{
			// everything is fine
			if (callback) callback(false);
		}
		else
		{
			// work through our list of tokens we need to update
			var step = function()
			{
				var func = todo.shift();
				if (!func)
				{
					// all done!
					if (callback) callback(false);
					return;
				}

				if (token_fetch.indexOf(func.func) >= 0)
				{
					// if we're actually calling a token fetch function, skip!
					process.nextTick(step);
				}
				else
				{
					func.func(function(error) {
						if (error)
						{
							// token fetching error!
							if (callback) callback(func.name + " :: " + error);
							return;
						}

						// do next step
						process.nextTick(step);
					});
				}
			};

			// start updating tokens
			process.nextTick(step);
		}
	}
852107
protected function processToken(): void
    {
        // "Sniff" the var name only once, but register the possible error everytime the var is declared.
        if (!$this->sniffedVars[$var = $this->token['content']]) {
            $this->file->recordMetric($this->stackPos, 'CamelCase var name', 'no');

            if (!$this->isSniffSuppressed(static::CODE_NOT_CAMEL_CASE)) {
                $this->file->addError(
                    self::MESSAGE_NOT_CAMEL_CASE,
                    $this->stackPos,
                    static::CODE_NOT_CAMEL_CASE,
                    [
                        $var
                    ]
                );
            }
        } else {
            $this->file->recordMetric($this->stackPos, 'CamelCase var name', 'yes');
        }
    }
1336689
function verifyFormToken(formToken) {
		/*jshint validthis:true */
		checkSecure(this);

		// If we already cached this token, we know that it's valid.
		// If we validate two different tokens for the same request,
		// this won't incorrectly skip the second one.
		if (this.res._csrfFormToken && this.res._csrfFormToken === formToken)
			return true;

		this._csrfChecked = true;
		if (!formToken) return false;

		var cookieToken = getCookieToken(this.res);
		if (!cookieToken) return false;

		var parts = formToken.split('|');

		// If the token is invalid, reject it.
		if (parts.length !== 2)
			return false;

		var hasher = crypto.createHmac(options.algorithm, formKey);
		hasher.update(cookieToken);
		hasher.update("|");	// Don't confuse longer or shorter tokens
		hasher.update(parts[0]);

		// If the hash doesn't match, reject the token
		if (parts[1] !== hasher.digest('base64'))
			return false;

		// If we have a valid token, reuse it for this request
		// instead of generating a new one. (saves crypto ops)
		if (!this.res._csrfFormToken)
			this.res._csrfFormToken = formToken;

		return true;
	}
180930
function hasValidToken (storageLocation) {
	var token = getStoredToken(storageLocation);
	if (token) {
		try {
			var payload = decode(token);
			return payloadIsValid(payload);
		} catch (error) {
			return false;
		}
	}
	return false;
}
573740
def _has_valid_token(self):
        
        return bool(self.token and (self.expires > datetime.datetime.now()))
342971
function refreshToken($accessToken, $sessionHandle) {
		$code = $this->request ( 'GET', $this->url ( 'AccessToken', '' ), array (
				'oauth_token' => $accessToken,
				'oauth_session_handle' => $sessionHandle 
		) );
		if ($this->response ['code'] == 200) {
			
			$response = $this->extract_params ( $this->response ['response'] );
			
			return $response;
		} else {
			$this->response ['helper'] = "TokenFatal";
			return $this->response;
		}
	}
521471
def check_session(self, key, *, session=None):
        
        self.append({
            "Verb": "check-session",
            "Key": key,
            "Session": extract_attr(session, keys=["ID"])
        })
        return self
1224601
def check_token(data: dict, token: str) -> bool:
    
    param_hash = data.get('hash', '') or ''
    return param_hash == generate_hash(data, token)
863756
private function verifyToken()
    {
        $received = Request::getReceivedData();

        if (is_array($received) && isset($received['hub_verify_token'])
            && strtolower($received['hub_verify_token']) == 'gigaai'
        ) {
            echo $received['hub_challenge'];

            exit;
        }
    }
156370
public function validateRequest(): bool
    {
        if ($this->useNativeSession) {
            if (!isset($_SESSION[$this->sessionIndex])) {
                return false;
            }
            /** @var array<string, array<string, mixed>> $sess */
            $sess =& $_SESSION[$this->sessionIndex];
        } else {
            if (!isset($this->session[$this->sessionIndex])) {
                return false;
            }
            /** @var array<string, array<string, mixed>> $sess */
            $sess =& $this->session[$this->sessionIndex];
        }

        if (
            empty($this->post[$this->formIndex]) ||
            empty($this->post[$this->formToken])
        ) {
            // User must transmit a complete index/token pair
            return false;
        }

        // Let's pull the POST data
        /** @var string $index */
        $index = $this->post[$this->formIndex];
        /** @var string $token */
        $token = $this->post[$this->formToken];
        if (!\is_string($index) || !\is_string($token)) {
            return false;
        }

        if (!isset($sess[$index])) {
            // CSRF Token not found
            return false;
        }

        if (!\is_string($index) || !\is_string($token)) {
            return false;
        }

        // Grab the value stored at $index
        /** @var array<string, mixed> $stored */
        $stored = $sess[$index];

        // We don't need this anymore
        if ($this->deleteToken($sess[$index])) {
            unset($sess[$index]);
        }

        // Which form action="" is this token locked to?
        /** @var string $lockTo */
        $lockTo = $this->server[$this->lock_type];
        if (\preg_match('#/$#', $lockTo)) {
            // Trailing slashes are to be ignored
            $lockTo = Binary::safeSubstr(
                $lockTo,
                0,
                Binary::safeStrlen($lockTo) - 1
            );
        }

        if (!\hash_equals($lockTo, (string) $stored['lockTo'])) {
            // Form target did not match the request this token is locked to!
            return false;
        }

        // This is the expected token value
        if ($this->hmac_ip === false) {
            // We just stored it wholesale
            /** @var string $expected */
            $expected = $stored['token'];
        } else {
            // We mixed in the client IP address to generate the output
            /** @var string $expected */
            $expected = Base64UrlSafe::encode(
                \hash_hmac(
                    $this->hashAlgo,
                    isset($this->server['REMOTE_ADDR'])
                        ? (string) $this->server['REMOTE_ADDR']
                        : '127.0.0.1',
                    (string) Base64UrlSafe::decode((string) $stored['token']),
                    true
                )
            );
        }
        return \hash_equals($token, $expected);
    }
74910
public static function check_token($value = null)
	{
		$value = $value ?: \Input::param(static::$csrf_token_key, \Input::json(static::$csrf_token_key, 'fail'));

		// always reset token once it's been checked and still the same
		if (static::fetch_token() == static::$csrf_old_token and ! empty($value))
		{
			static::set_token(true);
		}

		return $value === static::$csrf_old_token;
	}
1137261
def parse_session_token(self):
        
        session_file = os.path.join(self.file_path, 'session_token')
        # Only try to extract the strings if the file exists
        if os.path.isfile(session_file):
            # Create a list to store the data from the file
            session_list = list()
            with open(session_file, 'r') as session_token:
                for line in session_token:
                    # Split the description e.g. secret= from the line
                    value, data = line.split('=')
                    # Add each string to the list
                    session_list.append(data.rstrip())
            # Extract the appropriate variable from the list
            self.session_secret = session_list[0]
            self.session_token = session_list[1]
29242
def fetch_token(self, **kwargs):
        
        if 'client_secret' not in kwargs:
            kwargs.update(client_secret=self.client_secret)
        return self.session.fetch_token(token_url, **kwargs)
1026715
public function checkAuth() {
        if (isset($_SESSION[$this->_sessionVarName]) &&
            $_SESSION[$this->_sessionVarName] == 1
        ) {
            return true;
        } else {
            return false;
        }
    }
1275469
protected function isPrecededByOutputVar()
	{
		return ($this->tokens[$this->i - 1] === [T_STRING,          'out']
		     && $this->tokens[$this->i - 2] === [T_OBJECT_OPERATOR, '->']
		     && $this->tokens[$this->i - 3] === [T_VARIABLE,        '$this']);
	}
532082
def _oauth_tokengetter(token=None):
    
    token = session.get("oauth")
    log.debug("Token Get: {0}".format(token))
    return token
440925
public function check()
    {
        if($this->session->get('token') === $this->request->input('token') || $this->session->get('token') === $this->request->header('X-CSRF-TOKEN')) {
            return true;
        }

        return false;
    }