I am trying to get a Google user contact list. This getContacts () is called in doInBackground () for AsyncTask. I have - this moment - already received a token. I was based on this codeLab example: https://codelabs.developers.google.com/codelabs/appauth-android-codelab/#0
I am changing point n ° 10 of this manual, trying to get the user's contact list instead of the user's personal information (<which works)
private List<ContactEntry> getContacts() {
ContactsService contactsService = new ContactsService("MY_PRODUCT_NAME");
contactsService.setHeader("Authorization", "Bearer " + token);
try {
URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
Query myQuery = new Query(feedUrl);
ContactFeed resultFeed = contactsService.query(myQuery, ContactFeed.class);
List<ContactEntry> contactEntries = resultFeed.getEntries();
return contactEntries;
} catch (Exception e) {
}
return null;
}
My problem is that I always get an exception with this message:
java.lang.NullPointerException: No authentication header information
Any help? thanks in advance
source
share