checks whether the given oauth token match one on file
and returns the found login

@param  string        $oauth_token
@return $this|boolean false when the token is not found
543788
public static function get_by_oauth_token($oauth_token) {
	$mysql = bootstrap::get_library('mysql');
	
	$sql   = "SELECT * FROM `login_github` WHERE `oauth_token` = '%s';";
	$login = $mysql::select('row', $sql, $oauth_token);
	if (empty($login)) {
		return false;
	}
	
	return new static($login['id']);
}
61149
public function validateCompareWithPostToken(string $compare_token): bool
    {
        // No $_POST data means no token.
        if (empty($_POST)) {
            return true;
        }

        // Show warning in error log when using a form without a token
        if (empty($_POST[$this->token_name])) {

            if (isset($this->logger)) {
                $this->logger->notice(sprintf('Form data without proper token "%s" received. All data will be dropped.', $this->token_name));
            }

            return false;
        }

        // Token sent so let's check it
        if ($compare_token != $_POST[$this->token_name]) {

            if (isset($this->logger)) {
                $this->logger->warning('The token "%s" in $_POST is not he same as set compare token "%s". All data will be dropped.', [
                    $_POST[$this->token_name],
                    $this->compare_token
                ]);
            }

            return false;
        }

        unset($_POST[$this->token_name]);

        return true;
    }
733283
public static function extractUsernameFromToken($auth_token)
    {
        $token_info = (array) static::parse($auth_token);
        $username   = isset($token_info['username']) ? (string) $token_info['username'] : null;

        if (\is_string($username) && mb_strlen($username) >= 1) {
            if (mb_strpos($username, '@') !== false) {
                $just_username = mb_substr($username, 0, mb_strpos($username, '@'));
                if (mb_strlen($just_username) >= 1) {
                    return $just_username;
                }
            } else {
                return $username;
            }
        }
    }
373128
public static function info($access_token)
    {
        $opts = array('http' => array(
            'method'  => 'GET'
        ));

        $url = self::$clef_base_url."info?access_token=".$access_token;

        // exchange the oauth token for the user's info
        $context  = stream_context_create($opts);
        $response = file_get_contents($url, false, $context);

        if (!$response) {
            $response = json_decode($response, true);

            return $response;
        }

        return false;
    }
1189181
public function getOauthAuth($access_token,$openid){
        $result = $this->http_get(self::API_BASE_URL_PREFIX.self::OAUTH_AUTH_URL.'access_token='.$access_token.'&openid='.$openid);
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            } else
              if ($json['errcode']==0) return true;
        }
        return false;
    }
620160
protected function getToken()
    {
        $temp = $this->request->session()->get('oauth.temp');

        return $this->server->getTokenCredentials(
            $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
        );
    }
427358
private function useOAuthTokenFromCache()
    {
        if (!$this->use_cache_token) {
            return;
        }

        $this->oauth_tokens = \Cache::get($this->getOauthTokensCacheKey(), []);
        if (!empty($this->oauth_tokens)) {
            $this->printLine("Using OAuth Tokens from cache:");
            $this->printArray($this->oauth_tokens);
        }
    }
356390
public function lookup_token($consumer, $token_type, $token)
	{
  		\common_Logger::d(__CLASS__.'::'.__FUNCTION__.' called for token '.$token.' of type '.$token_type);
		return new OAuthToken($consumer, "");
	}
1028389
public function check()
	{
		$request = $this->app['request'];
		$getter = new TokenGetter( new Header($request), new  QueryStr($request));
		return $this->auth->check($getter, $this->secretKey);
	}
388019
public function callback($fallback_url = null)
    {
        if ($this->request->has('denied')) {
            return $this->redirect->to($fallback_url ?: $this->getFallbackUrl());
        } elseif ($this->request->has('oauth_verifier') && $this->session->has('oauth_request_verify')) {
            $this->twitter->setToken(
                $this->session->get('oauth_request_token'),
                $this->session->get('oauth_request_token_secret')
            );

            $this->session->forget('oauth_request_verify');

            $oauthVerifier = $this->request->get('oauth_verifier');

            $this->response = $this->twitter->api('POST', 'oauth/access_token', array('oauth_verifier' => $oauthVerifier));

            if ($this->responseOk()) {
                $this->session->forget('oauth_request_token');
                $this->session->forget('oauth_request_token_secret');
                $this->session->forget('oauth_request_verify');

                $data = array('oauth_token', 'oauth_token_secret', 'user_id', 'screen_name');
                foreach ($data as $key) {
                    $this->session->put("twitter.{$key}", $this->response->{$key});
                }

                return $this->response;
            }
            $this->triggerError("Invalid or expired token.");
        } else {
            $this->triggerError("To perform callback, you must authorize the user first.");
        }
    }
1025026
public function getOauthRefreshToken($refresh_token){
        $result = $this->http_get(self::API_BASE_URL_PREFIX.self::OAUTH_REFRESH_URL.'appid='.$this->appid.'&grant_type=refresh_token&refresh_token='.$refresh_token);
        if ($result)
        {
            $json = json_decode($result,true);
            if (!$json || !empty($json['errcode'])) {
                $this->errCode = $json['errcode'];
                $this->errMsg = $json['errmsg'];
                return false;
            }
            $this->user_token = $json['access_token'];
            return $json;
        }
        return false;
    }
1308729
public static function authenticate($auth_data)
    {
        $password = $auth_data['password'];
        $login = $auth_data['login'];

        // Small security check against the login
        if (preg_match('/[^A-Za-z0-9\-\_]/', $login)) {
            return false;
        }
        
        // We check the user against the LDAP server, if it works we
        // are happy, if not return false.


    	$ldap_dn = Pluf::f('auth_ldap_dn', 'ou=users,dc=example,dc=com');
        $ldap_user = Pluf::f('auth_ldap_user', null);
        $ldap_password = Pluf::f('auth_ldap_password', null);
        $ldap_version = Pluf::f('auth_ldap_version', 3);
        $ldap_user_key = Pluf::f('auth_ldap_user_key', 'uid');
        // If auth_ldap_password_key, it will use crypt hash control
        // to test the login password, else it will bind.
        $ldap_password_key = Pluf::f('auth_ldap_password_key', null);
        $ldap_surname_key = Pluf::f('auth_ldap_surname_key', 'sn');
        $ldap_givenname_key = Pluf::f('auth_ldap_givenname_key', 'cn');
        $ldap_email_key = Pluf::f('auth_ldap_email_key', 'mail');


		$ldap = ldap_connect(Pluf::f('auth_ldap_host', 'localhost'));
		ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 
                               Pluf::f('auth_ldap_version', 3));
		if (!ldap_bind($ldap, $ldap_user, $ldap_password)) {
            Pluf_Log::warn(sprintf('Cannot bind to the ldap server, user:%s, password:***', $ldap_user));
            ldap_close($ldap);
            return false;
        }
        // Go for a search
        $search = ldap_search($ldap, $ldap_dn, 
                              '('.$ldap_user_key.'='.$login.')', 
                              array($ldap_user_key, $ldap_surname_key, 
                                    $ldap_givenname_key, $ldap_email_key));
        $n = ldap_get_entries($ldap, $search);
        if ($n['count'] != 1) {
            ldap_close($ldap);
            return false;
        }
        $entry = ldap_first_entry($ldap, $search);
        // We get all the data first, the bind or hash control is done
        // later. If we control with bind now, we need to search again
        // to have an $entry resource to get the values.
        list($family_name,) = @ldap_get_values($ldap, $entry, $ldap_surname_key);
        list($first_name,) = @ldap_get_values($ldap, $entry, $ldap_givenname_key);
        list($email,) = @ldap_get_values($ldap, $entry, $ldap_email_key);
        $user_dn = ldap_get_dn($ldap, $entry);

        
        if ($ldap_password_key) {
            // Password authentication.
            list($ldap_hash,) = ldap_get_values($ldap, $entry, $ldap_password_key);
            $ldap_hash = substr($ldap_hash, 7);
            $salt = substr($ldap_hash, 0, 12);
            $hash = crypt($password, $salt);
            if ($ldap_hash != $hash) {
                ldap_close($ldap);
                return false;
            }
        } else {
            // Bind authentication
            if (!@ldap_bind($ldap, $user_dn, $password)) {
                ldap_close($ldap);
                return false;
            }
        }                
        // We get the user values as the 
        // Now we get the user and we create it if not available
        $user = self::getUser($login);
        if ($user) {
            ldap_close($ldap);
            return $user;
        }
        // Need to create it
        ldap_close($ldap);
        $user = new User();
        $user->active = true;
        $user->login = $login;
        $user->password = $password;
        $user->last_name = $family_name;
        $user->first_name = $first_name;
        $user->email = $email;
        $user->create();
        return $user;
    }
299800
public function getToken($authorization_code = null) {

		if ($authorization_code == null) {
			$authorization_code = $this->getAuthorizationCode();
		}

		$params = $_SESSION[$this->oauth_key];
		unset($_SESSION[$this->oauth_key]);

		$response = $this->client->post('oauth/token', [
			'client_id'		=> $this->client->id(),
			'grant_type'	=> 'authorization_code',
			'code'			=> $authorization_code,
			'scope'			=> $params['scope'],
			'redirect_uri'	=> $params['redirect_uri'],
		]);
		return $response->data('token');
	}
205615
public function getRefreshToken($refresh_token)
    {
        return isset($this->refreshTokens[$refresh_token]) ? $this->refreshTokens[$refresh_token] : false;
    }
790164
public function login($callback_url=NULL) {
		if (!$this->f3->exists('GET.oauth_token')) {
			$tokens = $this->requestToken();
			$this->setAuthToken($tokens['oauth_token'], $tokens['oauth_token_secret']);
			if(is_null($callback_url))
				$callback_url = $this->f3->get('SCHEME').'://'.$this->f3->get('HOST').
					$this->f3->get('URI');
			$this->authorize($callback_url);
		} else {
			return $this->accessToken();
		}
	}
1343486
protected function getToken()
    {
        if (!$this->isStateless()) {
            $temp = $this->request->getSession()->get('oauth.temp');

            return $this->server->getTokenCredentials(
                $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
            );
        }
        $temp = unserialize($this->request->session()->get('oauth_temp'));

        return $this->server->getTokenCredentials(
                $temp, $this->request->get('oauth_token'), $this->request->get('oauth_verifier')
            );
    }
1160078
def oauth_token=(new_oauth_token)
      @oauth_token = new_oauth_token.is_a?(Hash) ? OAuthToken.new(new_oauth_token) : new_oauth_token
      configure_oauth
    end