Hello.
When the following code is executed with user ID and password which is not
the user's password,
the following unexpected error occurs:
com.google.gdata.util.ServiceForbiddenException: Cannot request contacts
belonging to another user
The expected result should be AuthenticationException.
I'd like to know why instead I am getting the error:
com.google.gdata.util.ServiceForbiddenException: Cannot request contacts
belonging to another user
Thanks.
Masami Asai
-----------------------------------------
try {
String _useraddress ="[email protected]";
String gpass = "googlepassword";
Random rnd = new Random();
rnd.setSeed(new Date().getTime());
ContactsService myService = new ContactsService("exampleCo-exampleApp-1 "
+ rnd.nextInt());
// AddressBookUtil.logCnt("google_personal_contacts_auth");
myService.setUserCredentials(_useraddress, gpass);
System.out.println("auth ok");
URL feedUrl = new URL("https://www.google.com/m8/feeds/groups/" +
_useraddress + "/full?max-results=100000");
ContactGroupFeed resultFeed = myService.getFeed(feedUrl,
ContactGroupFeed.class);
String id = null;
Thread.sleep(6000);
System.out.println("finish!");
// } catch (LdapUtilException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
}catch(AuthenticationException e){
System.out.println("auth error");
}catch (Exception ee)
{
ee.printStackTrace();
}
-----------------------------------------
The result is as follows:
-----------------------------------------
auth ok
com.google.gdata.util.ServiceForbiddenException: Cannot request contacts
belonging to another user
<HTML>
<HEAD>
<TITLE>Cannot request contacts belonging to another user</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Cannot request contacts belonging to another user</H1>
<H2>Error 403</H2>
</BODY>
</HTML>
at
com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:561)
at
com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:543)
at
com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:536)
at
com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:515)
at
com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:515)
at com.google.gdata.client.Service.getFeed(Service.java:1073)
at com.google.gdata.client.Service.getFeed(Service.java:936)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:631)
at com.google.gdata.client.Service.getFeed(Service.java:955)
at test.main(test.java:67)
-----------------------------------------
--
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