title: gdata oauth2 authorization NullPointerException: No authentication header information
body: <p>I am trying to export/import google contacts using gdata+Oauth2 in my web application. The application has a client side on js and java server side, communicating through REST API. The js side performs auathorization via google getting the following data</p>
  
  <pre><code>{  
     state:"38c4ebb6-b763-4e98-969c-16a86221ec71",
     access_token:"ya29.BwEGCaDeWTzGqIwewwlmWreAMZdgNNexN1efOVGDcyY0f-gzXUot51F-Tzy5BX39CwGpbrL3JGjQ",
     token_type:"Bearer",
     expires_in:"3600"
  }
  </code></pre>
  
  <p>I am trying to use access_token to get the contacts in the following way</p>
  
  <pre><code>ContactsService myService = new ContactsService(APP_NAME);
  myService.setHeader("Authorization", "Bearer " + accessToken);
  return GoogleDataUtils.getContactList(getContactFeed(myService));
  </code></pre>
  
  <p>where</p>
  
  <pre><code>private ContactFeed getContactFeed(ContactsService myService) throws ServiceException, IOException {
          URL feedUrl = new URL(URL_FOR_FEED);
          Query myQuery = new Query(feedUrl);
          myQuery.setMaxResults(Integer.MAX_VALUE);
          ContactFeed resultFeed = myService.getFeed(myQuery, ContactFeed.class);
          return resultFeed;
      }
  </code></pre>
  
  <p>But what I get is</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException: No authentication header information
      at com.google.gdata.util.AuthenticationException.initFromAuthHeader(AuthenticationException.java:96)
      at com.google.gdata.util.AuthenticationException.&lt;init&gt;(AuthenticationException.java:67)
      at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:608)
      at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
      at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
      at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
      at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
      at com.google.gdata.client.Service.getFeed(Service.java:1135)
      at com.google.gdata.client.Service.getFeed(Service.java:1077)
      at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
      at com.google.gdata.client.Service.getFeed(Service.java:1034)
  </code></pre>
  
  <p>I've found a resolved question for SpreadsheetService</p>
  
  <p><a href="https://stackoverflow.com/questions/8228212/gdata-java-client-oauth2-access-token-secret">gdata-java-client + oauth2 + access_token secret</a></p>
  
  <p>But it did not work for me.</p>
  
  <p>Could you please point me to what am I doing wrong?
  Any help will be appreciated</p>
  
  <p>Thanks</p>