views:

17

answers:

0

I can successfully get a google AuthSub Token

But on running this code im getting the exception

java.lang.NullPointerException: No authentication header information

The code is

   ...
   ....
   ContactFeed contactFeed = getContactList(token);
   ...
   ....


   public ContactFeed getContactList(String token)
   {
        ContactFeed contactFeed = null;
        try
        {
            ContactsService contactsService = 
             new ContactsService("GoogleInc-jsguide-1.0");
            contactsService.setAuthSubToken(token);
            System.out.println("a");
            contactFeed = getAllContacts(contactsService);
        }

        catch (Exception e)
        {
            System.out.println(e);
        }
        return contactFeed;
}

 public ContactFeed getAllContacts(ContactsService myService)
 {
    ContactFeed resultFeed = null;
    try
    {
    URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/default/full");
    ContactQuery contactQuery = new ContactQuery(feedUrl);
    contactQuery.setMaxResults(1000);
    resultFeed = myService.getFeed(contactQuery, ContactFeed.class);
    }

    catch (ServiceException se)
    {
        System.out.println(se);
    }
    catch (IOException ie)
    {
        System.out.println(ie);
    }
    catch (Exception e)
    {
        System.out.println(e);
    }
    return resultFeed;
}

Any help

Can things get easier with OAuth??

Thanks