public function testGetRequestSchemeQueryStringClientSetsCorrectlyEncodedQueryString() { $request = new Zend_Oauth_Http_AccessToken($this->stubConsumer, null, $this->stubHttpUtility); $params = array('oauth_consumer_key' => '1234567890', 'oauth_nonce' => 'e807f1fcf82d132f9bb018ca6738a19f', 'oauth_signature_method' => 'HMAC-SHA1', 'oauth_timestamp' => '12345678901', 'oauth_token' => '0987654321', 'oauth_version' => '1.0', 'oauth_signature' => '6fb42da0e32e07b61c9f0251fe627a9c', 'custom_param1' => 'foo', 'custom_param2' => 'bar'); $client = $request->getRequestSchemeQueryStringClient($params, 'http://www.example.com'); $this->assertEquals('oauth_consumer_key=1234567890&oauth_nonce=e807f1fcf82d132f9bb018c' . 'a6738a19f&oauth_signature_method=HMAC-SHA1&oauth_timestamp=12345' . '678901&oauth_token=0987654321&oauth_version=1.0&oauth_signature=' . '6fb42da0e32e07b61c9f0251fe627a9c', $client->getUri()->getQuery()); }
/** * Retrieve an Access Token in exchange for a previously received/authorized * Request Token. * * @param array $queryData GET data returned in user's redirect from Provider * @param Zend_Oauth_Token_Request Request Token information * @param string $httpMethod * @param Zend_Oauth_Http_AccessToken $request * @return Zend_Oauth_Token_Access * @throws Zend_Oauth_Exception on invalid authorization token, non-matching response authorization token, or unprovided authorization token */ public function getAccessToken($queryData, Zend_Oauth_Token_Request $token, $httpMethod = null, Zend_Oauth_Http_AccessToken $request = null) { $authorizedToken = new Zend_Oauth_Token_AuthorizedRequest($queryData); if (!$authorizedToken->isValid()) { require_once 'Zend/Oauth/Exception.php'; throw new Zend_Oauth_Exception('Response from Service Provider is not a valid authorized request token'); } if ($request === null) { $request = new Zend_Oauth_Http_AccessToken($this); } // OAuth 1.0a Verifier if ($authorizedToken->getParam('oauth_verifier') !== null) { $params = array_merge($request->getParameters(), array('oauth_verifier' => $authorizedToken->getParam('oauth_verifier'))); $request->setParameters($params); } if ($httpMethod !== null) { $request->setMethod($httpMethod); } else { $request->setMethod($this->getRequestMethod()); } if (isset($token)) { if ($authorizedToken->getToken() !== $token->getToken()) { require_once 'Zend/Oauth/Exception.php'; throw new Zend_Oauth_Exception('Authorized token from Service Provider does not match' . ' supplied Request Token details'); } } else { require_once 'Zend/Oauth/Exception.php'; throw new Zend_Oauth_Exception('Request token must be passed to method'); } $this->_requestToken = $token; $this->_accessToken = $request->execute(); return $this->_accessToken; }
/** * Retrieve an Access Token in exchange for a previously received/authorised * Request Token. * * @param array $queryData GET data returned in user's redirect from Provider * @param Zend_Oauth_Token_Request Request Token information * @param string $httpMethod * @param Zend_Oauth_Http_AccessToken $request * @return Zend_Oauth_Token_Access */ public function getAccessToken($queryData, Zend_Oauth_Token_Request $token, $httpMethod = null, Zend_Oauth_Http_AccessToken $request = null) { $authorisedToken = new Zend_Oauth_Token_AuthorisedRequest($queryData); if (!$authorisedToken->isValid()) { require_once 'Zend/Oauth/Exception.php'; throw new Zend_Oauth_Exception('Response from Service Provider is not a valid authorised request token'); } if (is_null($request)) { $request = new Zend_Oauth_Http_AccessToken($this); } if (!is_null($httpMethod)) { $request->setMethod($httpMethod); } else { $request->setMethod($this->getRequestMethod()); } if (isset($token)) { if ($authorisedToken->getToken() !== $token->getToken()) { require_once 'Zend/Oauth/Exception.php'; throw new Zend_Oauth_Exception('Authorised token from Service Provider does not match supplied Request Token details'); } } else { require_once 'Zend/Oauth/Exception.php'; throw new Zend_Oauth_Exception('Request token must be passed to method'); } $this->_requestToken = $token; $this->_accessToken = $request->execute(); return $this->_accessToken; }