Hi,
I'm having trouble authenticating with the gdata
ContactsService.setUserCredentials() method. Could someone point me in
the right direction? Here is my code:
protected ContactFeed getGmailContact(String username, String
password) throws BussinessException{
try {
String email = username;
if (!email.contains("@")) {
email += "@gmail.com";
}
ContactsService service = new
ContactsService(SERVICE_NAME);
service.setConnectTimeout(60000);
service.setReadTimeout(60000);
service.setUserCredentials(email,
password,ClientLoginAccountType.HOSTED_OR_GOOGLE);
URL feedUrl = new
URL("https://www.google.com/m8/feeds/contacts/" +
email + "/full");
Query myQuery = new Query(feedUrl);
myQuery.setStringCustomParameter("group","http://www.google.com/m8/
feeds/groups/" + email + "/base/6");
myQuery.setMaxResults(10000);
return service.getFeed(myQuery,ContactFeed.class);
} catch (Exception e) {
throw new BussinessException(e);
}
And here is my error log:
com.google.gdata.util.AuthenticationException: Error connecting with
login URI
at
com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:
489)
at
com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:
346)
at
com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:
362)
at
com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:
317)
at
com.lenovo.lps.cloud.contact.web.portal.action.PortalGMailAction.getGmailContact(PortalGMailAction.java:
192)
at
com.lenovo.lps.cloud.contact.web.portal.action.PortalGMailAction.main(PortalGMailAction.java:
175)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown
Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown
Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown
Source)
at
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown
Source)
at
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown
Source)
at
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown
Source)
at
com.google.gdata.client.GoogleAuthTokenFactory.makePostRequest(GoogleAuthTokenFactory.java:
551)
at
com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:
487)
... 5 more
sometimes i can access it, sometimes throw error. who can help me or
give me some suggestion? thanks and regards.
--
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html