Note that there are some explanatory texts on larger screens.

plurals
  1. POInvalid credentials exception while Importing contact list from gmail contacts using Java in Linux only
    primarykey
    data
    text
    <p>I have using Google (GDATA) Gmail API for retrieving the contact list from gmail, It is working successfully on windows environment, but when I run the same code on Linux, I get error of Invalid Credentials. I googled it, but can't get much help,</p> <p>here is my code</p> <pre><code>public static String getGmailContactList() { String response = ""; StringBuilder str = new StringBuilder(); String statusString = ""; ArrayList list = new ArrayList(); ContactsService myService = new ContactsService(""); String email = "xxxxx@gmail.com"; String password = "xxxxxxxx"; try { try { myService.setUserCredentials(email, password); } catch (AuthenticationException ex) { ex.printStackTrace(); //****I got exception here when using this code on LINUX ENVIORMENT** *** } response = printAllContacts(myService, email); Iterator itr = list.iterator(); while (itr.hasNext()) { ArrayList contact = (ArrayList) itr.next(); try { str.append(contact.get(1)).append(","); } catch (Exception e) { log.debug("Exception ocurred inside fethching gmail contact &amp;gt; &amp;gt; &amp;gt; " + e); str.append("no contacts found"); } str.substring(0, str.length() - 1); } } catch (Exception ae) { response = statusString; log.debug("Exception ocurred inside ReadContacts : getGmailContactList()" + ae); } return response; } public static String printAllContacts(ContactsService myService, String emailSent)// throws ServiceException, IOException { URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/" + emailSent + "/full"); Query myQuery = new Query(feedUrl); myQuery.setMaxResults(100); ContactFeed resultFeed = myService.getFeed(myQuery, ContactFeed.class); String phones = null; String emails = null; log.debug(resultFeed.getTitle().getPlainText()); StringBuilder contacts = new StringBuilder(); contacts.append("&lt;?xml version=\"1.0\"&gt;&lt;Contacts&gt;"); for (int i = 0; i &lt; resultFeed.getEntries().size(); i++) { contacts.append("&lt;Contact&gt;"); ContactEntry entry = resultFeed.getEntries().get(i); if (entry.hasName()) { Name name = entry.getName(); if (name.hasFullName()) { String fullNameToDisplay = name.getFullName().getValue(); if (name.getFullName().hasYomi()) { fullNameToDisplay += " (" + name.getFullName().getYomi() + ")"; } contacts.append("&lt;Name&gt;").append(fullNameToDisplay).append("&lt;/Name&gt;"); } else { contacts.append("&lt;Name&gt;").append("").append("&lt;/Name&gt;"); } } else { contacts.append("&lt;Name&gt;").append("").append("&lt;/Name&gt;"); } StringBuilder emailIds = new StringBuilder(); if (entry.hasEmailAddresses()) { List&lt;Email&gt; email = entry.getEmailAddresses(); if (email != null &amp;&amp; email.size() &gt; 0) { for (Email e : email) { emailIds.append(e.getAddress()).append(","); } emailIds.trimToSize(); if (emailIds.indexOf(",") != -1) { emails = emailIds.substring(0, emailIds.lastIndexOf(",")); } contacts.append("&lt;Email&gt;").append(emails).append("&lt;/Email&gt;"); } else { contacts.append("&lt;Email&gt;").append("").append("&lt;/Email&gt;"); } } else { contacts.append("&lt;Email&gt;").append("").append("&lt;/Email&gt;"); } contacts.append("&lt;/Contact&gt;"); } contacts.append("&lt;/Contacts&gt;"); return contacts.toString(); } </code></pre> <p>so where I am lacking behind, some sort of help will be appriciated</p> <p>here is the stack trace</p> <pre> com.google.gdata.client.GoogleService$InvalidCredentialsException: Invalid credentials at com.google.gdata.client.GoogleAuthTokenFactory.getAuthException(GoogleAuthTokenFactory.java:660) at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:560) at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:397) at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:364) at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:319) at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:303) at com.gmail.ReadContacts.getGmailContactList(ReadContacts.java:55) </pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload