SilverHoodCorp / gdata-java-client

Automatically exported from code.google.com/p/gdata-java-client
Apache License 2.0
0 stars 0 forks source link

java.lang.NullPointerException: No authentication header information #368

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

While trying to access authorized user data i am facing following exception.
java.lang.NullPointerException: No authentication header information
    com.google.gdata.util.AuthenticationException.initFromAuthHeader(AuthenticationException.java:96)
    com.google.gdata.util.AuthenticationException.<init>(AuthenticationException.java:67)
    com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600)
    com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563)
    com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552)
    com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530)
    com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535)
    com.google.gdata.client.Service.getFeed(Service.java:1135)
    com.google.gdata.client.Service.getFeed(Service.java:1077)
    com.google.gdata.client.GoogleService.getFeed(GoogleService.java:662).....

i looked in to the other similar issues and tried the work around but its not 
working as of now.here is my code by which i am trying to fetch data

GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();

             oauthParameters.setOAuthConsumerKey("www.travellingrants.com");

             oauthParameters.setOAuthConsumerSecret("dViJqgTWSvBvulBmv0hIs9XI");
                GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(new OAuthHmacSha1Signer());
                oauthParameters.setScope(SCOPE);
                oauthParameters.setOAuthVerifier(oauth_verifier);
                oauthParameters.setOAuthToken(oauth_token);
                oauthParameters.setOAuthTokenSecret(oauth_token_secret)
                String token = oauthHelper.getAccessToken(oauthParameters);
                System.out.println("here");
                ContactsService  client=new ContactsService ("travellingrants-oauth-v1");
                client.setOAuthCredentials(oauthParameters, new OAuthHmacSha1Signer());
                URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
                ContactFeed resultFeed = client.getFeed(feedUrl, ContactFeed.class);
                for (int i = 0; i < resultFeed.getEntries().size(); i++) {
                    ContactEntry entry = (ContactEntry) resultFeed.getEntries().get(i);
                    System.out.println("|\t" + (i + 1) + ": "
                        + entry.getTitle().getPlainText());
                  }

it is failing at the following line
ContactFeed resultFeed = client.getFeed(feedUrl, ContactFeed.class);

Original issue reported on code.google.com by shekher....@gmail.com on 18 Nov 2011 at 2:37

GoogleCodeExporter commented 9 years ago
Note, you can work around this issue by modifying the client library's user 
agent: 
http://stackoverflow.com/questions/26286369/google-contacts-api-failing-to-refre
sh-access-token/26466985#26466985

Original comment by ekoleda+devrel@googlers.com on 20 Oct 2014 at 3:13