/** * Try to find the token for the provided request's token key. * * @param JacobKiers\OAuth\Request\RequestInterface $request * @param JacobKiers\OAuth\Consumer\ConsumerInterface $consumer * @param string $token_type * * @return JacobKiers\OAuth\Token\TokenInterface * * @throws JacobKiers\OAuth\OAuthException */ private function getToken(RequestInterface $request, ConsumerInterface $consumer, $token_type = 'access') { $token_key = $request instanceof RequestInterface ? $request->getOAuthToken() : null; $token = $this->data_store->lookupToken($consumer, $token_type, $token_key); if (!$token) { throw new OAuthException("Invalid {$token_type} token: {$token_key}"); } return $token; }