Пример #1
0
 public function testIsValidDetectsGoodResponse()
 {
     $body = 'oauth_token=jZaee4GF52O3lUb9&oauth_token_secret=J4Ms4n8sxjYc0A8K0KOQFCTL0EwUQTri';
     $response = new HTTPResponse();
     $response->setContent($body)->setStatusCode(200);
     $token = new RequestToken($response);
     $this->assertTrue($token->isValid());
 }
Пример #2
0
 /**
  * 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  \ZendOAuth\Token\Request Request Token information
  * @param  string $httpMethod
  * @param  \ZendOAuth\Http\AccessToken $request
  * @return \ZendOAuth\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;
 }
Пример #3
0
 public function testGetAccessTokenReturnsInstanceOfOauthTokenAccess()
 {
     $config = array('consumerKey' => '12345', 'consumerSecret' => '54321');
     $consumer = new Consumer($config);
     $rtoken = new Token\Request();
     $rtoken->setToken('token');
     $token = $consumer->getAccessToken(array('oauth_token' => 'token'), $rtoken, null, new AccessToken48231());
     $this->assertInstanceOf('ZendOAuth\\Token\\Access', $token);
 }