0

Looking for the proper code to change a Google email group's owner... what I have currently (not working). The credential/service are all fine, as I'm using them to do a bunch of other GoogleAPIs stuff which is working correctly. I'm just not sure whether I should be messing with a user or the group.


                String serviceAccountEmail = "asdfasdfasf@asdfasdfsdfsdf-323423.iam.gserviceaccount.com";
                var certificate = new X509Certificate2(@"c:\asdf\PasswordReset2.p12", "notasecret", X509KeyStorageFlags.Exportable);

                ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
                {
                    User = "andy@asdfasdfa.com",
                    Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser, DirectoryService.Scope.AdminDirectoryGroup }

                }.FromCertificate(certificate));

                var service = new DirectoryService
                (
                    new BaseClientService.Initializer()
                    {
                        HttpClientInitializer = credential,
                        ApplicationName = "jimmyjohn",
                        ApiKey = "asdkfjasl;dkjfaskdjfasdfasdf"
                    }
                );

                Group g = new Group();
                g = service.Groups.Get(groupemail).Execute();

                // NEED HELP HERE

                service.Groups.Update(g, groupemail).Execute();
                
                //Member newMember = new Member();
                //newMember.Email = useremail;
                //newMember.Role = "OWNER"; //MANAGER , OWNER
                //newMember.Kind = "admin#directory#member";

                //service.Members.Update(newMember, groupemail, useremail).Execute();```
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Andy
  • 25
  • 5
  • did you try https://developers.google.com/admin-sdk/directory/v1/reference/groups/patch – Linda Lawton - DaImTo Sep 24 '20 at 18:11
  • yes, that's my starting point for all the Google stuff, but I can't figure out how to connect the dots between their syntax and what I need to accomplish. – Andy Sep 24 '20 at 18:56

1 Answers1

1

I already had the answer, but due to a facepalm bug I was always telling it to set the owner to myself (in a previous function feeding this one), hence never seeing anything change in Google Groups...

Member newMember = new Member
{
     Email = useremail,
     Role = "OWNER" //MANAGER , OWNER
};

service.Members.Update(newMember, groupemail, useremail).Execute();
Andy
  • 25
  • 5