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

145 views Asked by At
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");
    }

}

My objective to get the friends contacts list from gmail and 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.

0

There are 0 answers