Get a specific server token for the given user

@param string consumer_key
@param string token
@param int user_id
@exception OAuthException2 when no such token found
@return array
424933
public function getServerToken ( $consumer_key, $token, $user_id )
	{
		$ts = $this->query_row_assoc('
					SELECT	ocr_consumer_key		as consumer_key,
							ocr_consumer_secret		as consumer_secret,
							oct_token				as token,
							oct_token_secret		as token_secret,
							oct_usa_id_ref			as usr_id,
							ocr_signature_methods	as signature_methods,
							ocr_server_uri			as server_uri,
							ocr_server_uri_host		as server_uri_host,
							ocr_server_uri_path		as server_uri_path,
							ocr_request_token_uri	as request_token_uri,
							ocr_authorize_uri		as authorize_uri,
							ocr_access_token_uri	as access_token_uri,
							oct_timestamp			as timestamp
					FROM oauth_consumer_registry
							JOIN oauth_consumer_token
							ON oct_ocr_id_ref = ocr_id
					WHERE ocr_consumer_key = \'%s\'
					  AND oct_usa_id_ref   = %d
					  AND oct_token_type   = \'access\'
					  AND oct_token        = \'%s\'
					  AND oct_token_ttl    >= NOW()
					', $consumer_key, $user_id, $token);
		
		if (empty($ts))
		{
			throw new OAuthException2('No such consumer key ('.$consumer_key.') and token ('.$token.') combination for user "'.$user_id.'"');
		}
		return $ts;
	}
679753
protected function get_url_with_auth( $consumer_key, $consumer_secret ) {

		$auth = new WC_API_Client_Authentication( $this->request->url, $consumer_key, $consumer_secret );

		if ( $auth->is_ssl() ) {

			// query string authentication over SSL works with all servers, whereas HTTP basic auth fails in certain cases
			// see https://github.com/kloon/WooCommerce-REST-API-Client-Library/issues/29
			$this->request->params = array_merge( $this->request->params, array(
				'consumer_key'    => $auth->get_consumer_key(),
				'consumer_secret' => $auth->get_consumer_secret(),
			) );

		} else {

			$this->request->params = array_merge( $this->request->params, $auth->get_oauth_params( $this->request->params, $this->request->method ) );
		}

		// build url
		return $this->request->url . ( ! empty( $this->request->params ) ? '?' . http_build_query( $this->request->params ) : '' );
	}
1322328
public function getClientUser($client_id, $user_id)
    {
        $sql = 'SELECT * from %s where client_id = :client_id and user_id = :user_id';
        $sql = sprintf($sql, $this->config['client_user_table']);

        return $this->fetch($sql, compact('client_id', 'user_id'));
    }
1346459
function getRequestToken($oauth_callback = NULL)
    {
        $parameters = [];
        if (!empty($oauth_callback)) {
            $parameters['oauth_callback'] = $oauth_callback;
        }
        $request = $this->oAuthRequest($this->requestTokenURL(), 'GET', $parameters);
        $token = OAuthUtil::parse_parameters($request);
        $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
        return $token;
    }
863396
def get_token(self, user_id):
        
        if not self.jwt_implementation:
            return self.default_token_implementation(user_id)

        try:
            implementation = import_string(self.jwt_implementation)
        except ImportError:
            msg = 'Failed to import custom JWT implementation. '
            msg += 'Check that configured module exists [{}]'
            raise x.ConfigurationException(msg.format(self.jwt_implementation))

        # return custom token
        return implementation(user_id)
453642
function lookup_consumer($consumerKey)
    {

        return new OAuth\OAuthConsumer($this->toolProvider->consumer->getKey(),
           $this->toolProvider->consumer->secret);

    }
966468
public function getConsumer ( $consumer_key, $user_id, $user_is_admin = false )
    {
        $consumer = $this->query_row_assoc('
                        SELECT    *
                        FROM oauth_server_registry
                        WHERE osr_consumer_key = \'%s\'
                        ', $consumer_key);

        if (!is_array($consumer))
        {
            throw new OAuthException2('No consumer with consumer_key "'.$consumer_key.'"');
        }

        $c = array();
        foreach ($consumer as $key => $value)
        {
            $c[substr($key, 4)] = $value;
        }
        $c['user_id'] = $c['usa_id_ref'];

        if (!$user_is_admin && !empty($c['user_id']) && $c['user_id'] != $user_id)
        {
            throw new OAuthException2('No access to the consumer information for consumer_key "'.$consumer_key.'"');
        }
        return $c;
    }
678105
public function findOauthConsumerResource($consumer_key)
	{
		$returnValue = null;

		$class = $this->getClass(self::CLASS_URI_OAUTH_CONSUMER);
		$instances = $class->searchInstances(array(self::PROPERTY_OAUTH_KEY => $consumer_key), array('like' => false, 'recursive' => true));
		if (count($instances) == 0) {
			throw new \tao_models_classes_oauth_Exception('No Credentials for consumer key '.$consumer_key);
		}
		if (count($instances) > 1) {
			throw new \tao_models_classes_oauth_Exception('Multiple Credentials for consumer key '.$consumer_key);
		}
		$returnValue	= current($instances);

		return $returnValue;
	}
456562
public function GetUserFromCache($UserToken, $TokenType) {
      if ($TokenType == 'name') {
         $UserNameKey = FormatString(self::USERNAME_KEY, array('Name' => md5($UserToken)));
         $UserID = Gdn::Cache()->Get($UserNameKey);
         
         if ($UserID === Gdn_Cache::CACHEOP_FAILURE) return FALSE;
         $UserToken = $UserID; $TokenType = 'userid';
      } else {
         $UserID = $UserToken;
      }
      
      if ($TokenType != 'userid') return FALSE;
      
      // Get from memcached
      $UserKey = FormatString(self::USERID_KEY, array('UserID' => $UserToken));
      $User = Gdn::Cache()->Get($UserKey);
      
      return $User;
   }
1066674
public function deleteServer ( $consumer_key, $user_id, $user_is_admin = false )
	{
		if ($user_is_admin)
		{
			$this->query('
					DELETE FROM oauth_consumer_registry
					WHERE ocr_consumer_key = \'%s\'
					  AND (ocr_usa_id_ref = %d OR ocr_usa_id_ref IS NULL)
					', $consumer_key, $user_id);
		}
		else
		{
			$this->query('
					DELETE FROM oauth_consumer_registry
					WHERE ocr_consumer_key = \'%s\'
					  AND ocr_usa_id_ref   = %d
					', $consumer_key, $user_id);
		}
	}
728728
public function getClientKey($client_id, $subject)
    {
        if (isset($this->jwt[$client_id])) {
            $jwt = $this->jwt[$client_id];
            if ($jwt) {
                if ($jwt["subject"] == $subject) {
                    return $jwt["key"];
                }
            }
        }

        return null;
    }
935031
public static function get_user_info($oauth_token) {
	$url     = 'https://api.github.com/user';
	$options = [
		'headers' => [
			'Accept' => 'application/json',
			'Authorization' => 'token '.$oauth_token,
		],
	];
	
	$http = new \GuzzleHttp\Client();
	return $http->get($url, $options)->json();
}
1180969
public function getUserId() {
    if (array_key_exists(self::USER_ATTR, $this->payload)) {
      return $this->payload[self::USER_ATTR];
    }
    throw new Exception("No user_id in token");
  }
1308164
private function get_consumer($request)
    {
        $consumer_key = $request instanceof Twitter_OAuthRequest
            ? $request->get_parameter('oauth_consumer_key')
            : null;

        if (!$consumer_key) {
            throw new Twitter_OAuthException('Invalid consumer key');
        }

        $consumer = $this->data_store->lookup_consumer($consumer_key);
        if (!$consumer) {
            throw new Twitter_OAuthException('Invalid consumer');
        }

        return $consumer;
    }
827616
public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
    {
        try {
            $event = new ApiAuthenticateEvent();

            if (null !== $token->getCredentials()) {
                $event->setUserName($token->getUsername());
                $event->setPassword($token->getCredentials());
                $this->dispatcher->dispatch(ApiAuthenticationEvents::AUTHENTICATE, $event);
            } elseif ($token->getUser() instanceof User) {
                //if we have no password then only way to authenticate is by api key
                $event->setApiKey($token->getUser()->getApiKey());
                $this->dispatcher->dispatch(ApiAuthenticationEvents::API_KEY_AUTHENTICATE, $event);
            }

            $user = $userProvider->loadUserByUsername($token->getUsername());
        } catch (UsernameNotFoundException $e) {
            throw new AuthenticationException($e->getMessage());
        }

        return new UsernamePasswordToken(
            $user,
            $user->getPassword(),
            $providerKey,
            $user->getRoles()
        );
    }
436683
public function receiveToken($consumer_key, $request_token)
    {
        $pocketData = $this->convertRequestToken($consumer_key, $request_token);

        $access_token = $pocketData->access_token;

        return $access_token;
    }
278925
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
    @$parameters or $parameters = array();
    $defaults = array("oauth_version" => OAuthRequest::$version,
                      "oauth_nonce" => OAuthRequest::generate_nonce(),
                      "oauth_timestamp" => OAuthRequest::generate_timestamp(),
                      "oauth_consumer_key" => $consumer->key);
    if ($token)
      $defaults['oauth_token'] = $token->key;

    $parameters = array_merge($defaults, $parameters);

    // Parse the query-string to find and add GET parameters
    $parts = parse_url($http_url);
    if ( !empty($parts['query']) ) {
      $qparms = OAuthUtil::parse_parameters($parts['query']);
      $parameters = array_merge($qparms, $parameters);
    }


    return new OAuthRequest($http_method, $http_url, $parameters);
  }