Issues

ZF2-267: PHP 5.4 + Zend GDATA + YouTube + OAuth Consumer => No Request Token

Description

  • we want to create a youtube connection via OAuth (as on PHP 5.2 and ZF 1.11):

...

$this->oauthoptions = array( 'requestScheme' => \Zend\OAuth\OAuth::REQUEST_SCHEME_HEADER, 'version' => '1.0', 'consumerKey' => self::GOOGLEAPI_KEY, 'consumerSecret' => self::GOOGLEAPI_SECRET, 'signatureMethod' => 'HMAC-SHA1', 'callbackUrl' => self::CALLBACK_URL, 'requestTokenUrl' => 'https://google.com/accounts/OAuthGetRequestToken/', 'userAuthorizationUrl' => 'https://google.com/accounts/OAuthAuthorizeToken/', 'accessTokenUrl' => 'https://google.com/accounts/OAuthGetAccessToken/' ); $this->consumer=new \Zend\OAuth\Consumer($this->oauthoptions);

  • this should then lead to RequestTokens: $this->consumer->getRequestToken(array('scope' => 'http://gdata.youtube.com'));

BUT the following is the result:

ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/OAuth.php -> Zend\OAuth\OAuth ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/Consumer.php -> Zend\OAuth\Consumer ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/Config/StandardConfig.php -> Zend\OAuth\Config\StandardConfig ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/Config.php -> Zend\OAuth\Config ZEND AUTOLOAD: .../libraries/gdata/Zend/Uri/UriFactory.php -> Zend\Uri\UriFactory ZEND AUTOLOAD: .../libraries/gdata/Zend/Uri/Uri.php -> Zend\Uri\Uri ZEND AUTOLOAD: .../libraries/gdata/Zend/Uri/Http.php -> Zend\Uri\Http ZEND AUTOLOAD: .../libraries/gdata/Zend/Validator/Hostname.php -> Zend\Validator\Hostname ZEND AUTOLOAD: .../libraries/gdata/Zend/Validator/AbstractValidator.php -> Zend\Validator\AbstractValidator ZEND AUTOLOAD: .../libraries/gdata/Zend/Validator/Validator.php -> Zend\Validator\Validator ZEND AUTOLOAD: .../libraries/gdata/Zend/Validator/Ip.php -> Zend\Validator\Ip ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/Http/UserAuthorization.php -> Zend\OAuth\Http\UserAuthorization ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/Http.php -> Zend\OAuth\Http ZEND AUTOLOAD: .../libraries/gdata/Zend/OAuth/Http/Utility.php -> Zend\OAuth\Http\Utility Fatal error: Call to a member function getToken() on a non-object in ....libraries/gdata/Zend/OAuth/Http/UserAuthorization.php on line 60

and actually, the reason is /Zend/OAuth/Http/UserAuthorization: -> _consumer->getLastRequestToken() returns NULL, so everything else failed.

public function assembleParams() { $params = array( 'oauth_token' => $this->_consumer->getLastRequestToken()->getToken(), ); ... return $params; }

Thanks for your Efforts! Christoph, Germany

Comments

problem found. double call of getRequestTokens.