I'm semi-familiar with the ZendFramework/ZendOAuth library found here https://github.com/zendframework/ZendOAuth
I am able to use it no problem with Twitter, but I can't figure out how to get it to work with Google OAuth 2.0. The code I'm trying to use is as follows:
$config = array(
'callbackUrl' => 'https://www.example.com/callback',
'siteUrl' => 'https://accounts.google.com/o/oauth2',
'userAuthorizationUrl' => 'https://accounts.google.com/o/oauth2/auth',
'requestTokenUrl' => 'https://accounts.google.com/o/oauth2/token',
'consumerKey' => 'MY-CONSUMER-KEY-HERE',
'consumerSecret' => 'MY-SECRET-KEY-HERE',
'version' => '2.0',
);
$scopes = array(
'https://www.googleapis.com/oauth2/v2/userinfo'
);
$consumer = new Consumer($config);
$token = $consumer->getRequestToken(array('scope' => implode('', $scopes), 'response_type' => 'code', 'redirect_uri' => 'https://www.example.com/callback'));
$consumer->redirect();
According to the documentation for ZendOAuth, an array in the getRequestToken function gets treated as custom OAuth parameters. However, when I run this code I get redirected to a Google page that says:
Required parameter is missing: response_type
The URL in the browser shows the following:
I've tried throwing debug statements around in the ZendOAuth library, but I can't seem to be able to find the problem.
If anyone has a solution to this, it would be much appreciated.
Thanks,