google / gdata-java-client

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

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

Open gurmeetsingh90 opened 7 years ago

gurmeetsingh90 commented 7 years ago

` private void setOauthParameter() { GoogleOAuthParameters oauthParam = new GoogleOAuthParameters(); oauthParam.setOAuthConsumerKey(ClientId); oauthParam.setOAuthConsumerSecret(ClientSecrate); oauthParam.setOAuthType(OAuthParameters.OAuthType.TWO_LEGGED_OAUTH); // Init the service and set the auth service = new ContactsService("chat.com.contactssharing"); try { service.setOAuthCredentials(oauthParam, new OAuthHmacSha1Signer());

        service.getRequestFactory().setHeader("User-Agent", "chat.com.contactssharing");

    } catch (OAuthException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

private void queryEntries() throws IOException, ServiceException { Query myQuery = new Query(feedUrl); myQuery.setMaxResults(50); myQuery.setStartIndex(1); myQuery.setStringCustomParameter("showdeleted", "false"); myQuery.setStringCustomParameter("requirealldeleted", "false"); myQuery.setStringCustomParameter("sortorder", "ascending");

   try {
             // Execution of this line i'm getting an exception
        ContactFeed resultFeed = (ContactFeed) this.service.query(myQuery, ContactFeed.class);
        Log.d(TAG, resultFeed.toString());
        for (ContactEntry entry : resultFeed.getEntries()) {
            printContact(entry);
        }
        System.err.println("Total: " + resultFeed.getEntries().size() + " entries found");

    } catch (Exception ex) {
        System.err.println("Not all placehorders of deleted entries are available");
    }

}

`

I have check no's of post for this Exception but no one is commented by correct solution.It's become blocker for me so please help me to out this problem and guide what is doing wrong at above code.