Hi David,

Group Membership should work with OAuth, I was able to create a Group
and add a Contact to it using OAuth with the following sample:

ContactsService myService = new ContactsService("domain.com");
OAuthSigner signer = new OAuthHmacSha1Signer();
GoogleOAuthParameters oauthParameters = new GoogleOAuthParameters();
oauthParameters.setOAuthConsumerKey("domain.com");
oauthParameters.setOAuthConsumerSecret("gy......");
oauthParameters.setScope("http://www.google.com/m8/feeds/";);
myService.setOAuthCredentials(oauthParameters, signer);

URL feedUrl = new
URL("http://www.google.com/m8/feeds/contacts/default/full?
[email protected]");

ContactGroupEntry newGroup = new ContactGroupEntry();
newGroup.setTitle(new PlainTextConstruct("OauthGroup"));

String feedGroupUrlInsert =
"http://www.google.com/m8/feeds/groups/default/full?
[email protected]";
URL postGroupUrl = new URL(feedGroupUrlInsert);

newGroup = myService.insert(postGroupUrl, newGroup);

ContactEntry contactEntry = new ContactEntry();
contactEntry.setTitle(new PlainTextConstruct("TestContactOauth"));
Email primaryMail = new Email();
primaryMail.setAddress("[email protected]");
primaryMail.setRel("http://schemas.google.com/g/2005#home";);
primaryMail.setPrimary(true);
contactEntry.addEmailAddress(primaryMail);

GroupMembershipInfo groupMembershipInfo = new GroupMembershipInfo();
groupMembershipInfo.setHref(newGroup.getId());
contactEntry.addGroupMembershipInfo(groupMembershipInfo);

myService.insert( feedUrl, contactEntry );

Cheers,
Julian.

On Mar 24, 11:29 pm, David Cifuentes <[email protected]> wrote:
> I forgot to mention that if I switch to the the ClientLogin
> authentication it works fine. Is it a constraint about using
> GroupMembershipInfo with oauth??
>
> Thanks,
>
> David
>
> On 24 mar, 00:17, David Cifuentes <[email protected]> wrote:
>
> > Hello,
>
> > I'm trying to add contacts inside a group using OAuth. The group and
> > contacts creation works fine. When I try to add the
> > GroupMembershipInfo object it throws an
> > com.google.gdata.util.InvalidEntryException: Bad Request Group
> > membership information not supported. Here is the code...
>
> >             //two-legged oauth initialization
> >             GoogleOAuthParameters oauthParameters = new 
> > GoogleOAuthParameters
> > ();
>
> >             oauthParameters.setOAuthConsumerKey(domain);
>
> >             oauthParameters.setOAuthConsumerSecret(secret);
> >             OAuthSigner signer = new OAuthHmacSha1Signer();
>
> >             GoogleOAuthHelper oauthHelper = new GoogleOAuthHelper(signer);
>
> >             oauthParameters.setScope(scope);
>
> >             ContactsService contactsService = new ContactsService(appTitle);
> >             contactsService.setOAuthCredentials(oauthParameters, signer);
>
> >             // Create group the entry to insert
> >             ContactGroupEntry group = new ContactGroupEntry();
> >             group.setTitle(new PlainTextConstruct(groupName));
>
> >             // Create the contact object
> >             ContactEntry contact = new ContactEntry();
> >             contact.setTitle(new PlainTextConstruct(name));
>
> >             // Ask the service to insert the new group entry
> >             String feedGroupUrlInsert = feedGroupUrlString;
> >             feedGroupUrlInsert += "?xoauth_requestor_id=" + currentUser + 
> > "@"
> > + domain;
> >             URL postGroupUrl = new URL(feedGroupUrlInsert);
> >             group = contactsService.insert(postGroupUrl, group);
>
> >             //Create a group membership info object
> >             GroupMembershipInfo groupInfo = new GroupMembershipInfo();
> >             groupInfo.setDeleted(false);
> >             groupInfo.setHref(group.getId());
> >             contact.addGroupMembershipInfo(groupInfo);
>
> >             //Add the contact
> >             String feedUrlInsert = feedContactUrlString;
> >             feedUrlInsert += "?xoauth_requestor_id=" + currentUser + "@" +
> > domain;
> >             URL postContactUrl = new URL(feedUrlInsert);
> >             contact = contactsService.insert(postContactUrl, contact);
>
> > Thanks for any help,
>
> > David Cifuentes
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts API" 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://groups.google.com/group/google-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to