java.lang.NullPointerException:没有身份验证标头信息#467

时间:2016-12-26 13:46:03

标签: android performance google-contacts

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");
    }

}

我的目标是从gmail获取朋友联系人列表,我已经检查了此例外的帖子,但是没有人通过正确的解决方案进行评论。这对我来说已成为阻碍者所以请帮我解决这个问题并指导做什么上面的代码错了。

0 个答案:

没有答案