public function testGetRequestSchemeQueryStringClientSetsCorrectlyEncodedQueryString() { $request = new 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 Exception\InvalidArgumentException on invalid authorization token, non-matching response authorization token, or unprovided authorization token */ public function getAccessToken($queryData, Token\Request $token, $httpMethod = null, Http\AccessToken $request = null) { $authorizedToken = new Token\AuthorizedRequest($queryData); if (!$authorizedToken->isValid()) { throw new Exception\InvalidArgumentException('Response from Service Provider is not a valid authorized request token'); } if ($request === null) { $request = new 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()) { throw new Exception\InvalidArgumentException('Authorized token from Service Provider does not match' . ' supplied Request Token details'); } } else { throw new Exception\InvalidArgumentException('Request token must be passed to method'); } $this->_requestToken = $token; $this->_accessToken = $request->execute(); return $this->_accessToken; }