title: Access Google Contacts API on Ruby
body: <p>I'm struggling to access the Google Contacts API.</p>
  
  <p>First I tried the <code>google-api-ruby-client</code> gem but it turned out that it <a href="https://github.com/google/google-api-ruby-client/issues/136" rel="nofollow">does not support the Contacts API</a>.</p>
  
  <p>Next shot was the <code>google_contacts_api</code> <a href="https://github.com/aliang/google_contacts_api" rel="nofollow">gem</a> but I struggle to get a <code>oauth_access_token_for_user</code> with the <code>oAuth2</code> <a href="https://github.com/intridea/oauth2" rel="nofollow">gem</a>. When following the <a href="https://github.com/intridea/oauth2#usage-examples" rel="nofollow">oAuth2 instructions</a> I don't know what to put in <code>authorization_code_value</code> and <code>Basic some_password</code>.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>require 'oauth2'
  client = OAuth2::Client.new(ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], :site =&gt; 'http://localhost:9292')
  =&gt; #&lt;OAuth2::Client:0x007fcf88938758 @id="blabla.apps.googleusercontent.com", @secret="blabla", @site="http://localhost:9292", @options={:authorize_url=&gt;"/oauth/authorize", :token_url=&gt;"/oauth/token", :token_method=&gt;:post, :connection_opts=&gt;{}, :connection_build=&gt;nil, :max_redirects=&gt;5, :raise_errors=&gt;true}&gt;
  
  client.auth_code.authorize_url(:redirect_uri =&gt; 'http://localhost:9292')
  =&gt; "http://localhost:9292/oauth/authorize?client_id=blabla.apps.googleusercontent.com&amp;redirect_uri=http%3A%2F%2Flocalhost%3A9292&amp;response_type=code"
  
  token = client.auth_code.get_token('authorization_code_value', :redirect_uri =&gt; 'http://localhost:9292', :headers =&gt; {'Authorization' =&gt; 'Basic some_password'})
  =&gt; Faraday::ConnectionFailed: Connection refused - connect(2) for "localhost" port 9292
  </code></pre>
  
  <p>I would appreciate if someone could give me detailed step by step instructions how to access the API.</p>