コード例 #1
0
ファイル: AccessTokenTest.php プロジェクト: rexmac/zf2
 public function testConstructorSetsCustomServiceParameters()
 {
     $request = new Http\AccessToken($this->stubConsumer, array(1, 2, 3), $this->stubHttpUtility);
     $this->assertEquals(array(1, 2, 3), $request->getParameters());
 }
コード例 #2
0
ファイル: Consumer.php プロジェクト: robertodormepoco/zf2
 /**
  * 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;
 }