Google Apps Profile API: java.lang.NullPointerException: No authentication header information

public ContactFeed retrieveContacts(ContactsService service,
                                    Credential credential) throws Exception {

    URL url = new URL("https://www.google.com/m8/feeds/profiles/domain/my.domain.com/full");

    service.setOAuth2Credentials(credential);
    service.useSsl();
    service.setHeader("GData-Version", "3.0");

    ContactFeed contactFeed = new ContactFeed();

    do {
        ContactFeed feedResult = service.getFeed(url, ContactFeed.class);
        contactFeed.getEntries().addAll(feedResult.getEntries());

        if (feedResult.getNextLink() != null && feedResult.getNextLink().getHref() != null
                && !feedResult.getNextLink().getHref().isEmpty()) {
            url = new URL(feedResult.getNextLink().getHref());
        } else {
            url = null;
        }
    } while (url != null);

    return contactFeed;
}

This is my code for getting profiles. When executing this line

ContactFeed feedResult = service.getFeed(query, ContactFeed.class);

It will give java.lang.NullPointerException: missing header information .

Google, Google , Google Apps Provisioning, Google OAuth2. Google Apps OAuth2 java.lang.NullPointerException: . , , ? , , - AccessToken . , ? Cron Job, OAuth2.

====

Edit:

set header :

service.setHeader("GData-Version", "3.0");
service.setUserCredentials(myusername, mypassword);

. service.setOAuth2Credentials(), , .

+3
2

, service.setOAuth2Credentials() Google ( P12File).

, service.setOAuth2Credentials() REFRESH TOKEN , Google , Google ..

Google P12File, Google.

googleCredential.refreshToken();

, ContactsService.setOAuth2Credentials().

+4

SecureSociale .

, SecureSociale.

, .

0

All Articles