title: Zend Framework 2 ZendOAuth with Google
body: <p>I'm semi-familiar with the ZendFramework/ZendOAuth library found here <a href="https://github.com/zendframework/ZendOAuth" rel="nofollow">https://github.com/zendframework/ZendOAuth</a></p>
  
  <p>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:</p>
  
  <pre><code>$config = array(
          'callbackUrl' =&gt; 'https://www.example.com/callback',
          'siteUrl' =&gt; 'https://accounts.google.com/o/oauth2',
          'userAuthorizationUrl' =&gt; 'https://accounts.google.com/o/oauth2/auth',
          'requestTokenUrl' =&gt; 'https://accounts.google.com/o/oauth2/token',
          'consumerKey' =&gt; 'MY-CONSUMER-KEY-HERE',
          'consumerSecret' =&gt; 'MY-SECRET-KEY-HERE',
          'version' =&gt; '2.0',
      );
  
      $scopes = array(
          'https://www.googleapis.com/oauth2/v2/userinfo'
      );
  
      $consumer = new Consumer($config);
      $token = $consumer-&gt;getRequestToken(array('scope' =&gt; implode('', $scopes), 'response_type' =&gt; 'code', 'redirect_uri' =&gt; 'https://www.example.com/callback'));
      $consumer-&gt;redirect();
  </code></pre>
  
  <p>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:</p>
  
  <p><strong>Required parameter is missing: response_type</strong></p>
  
  <p>The URL in the browser shows the following:</p>
  
  <p><a href="https://accounts.google.com/o/oauth2/auth?oauth_token=&amp;oauth_callback=https%3A%2F%2Fwww.example.com%2Fcallback" rel="nofollow">https://accounts.google.com/o/oauth2/auth?oauth_token=&amp;oauth_callback=https%3A%2F%2Fwww.example.com%2Fcallback</a></p>
  
  <p>I've tried throwing debug statements around in the ZendOAuth library, but I can't seem to be able to find the problem.</p>
  
  <p>If anyone has a solution to this, it would be much appreciated.</p>
  
  <p>Thanks,</p>