Googleのユーザーとグループを管理するためにGoogle.Apis.Admin.Directory.directory_v1.Dataを使用しています。私はユーザーとグループを作成できますが、新しいユーザーを新しいグループに挿入する方法はありますか?ここ は、パラメータとして、電子メールを追加し、役割のように私のコードGoogle apiでグループにユーザーを挿入する方法
static void Main(string[] args)
{
UserCredential credential;
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/admin-directory_v1-dotnet-quickstart.json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
new string[] { DirectoryService.Scope.AdminDirectoryGroup, DirectoryService.Scope.AdminDirectoryUser },
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}
var service = new DirectoryService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Directory API .NET Quickstart",
});
User user = new User();
UserName username = new UserName();
user.PrimaryEmail = "[email protected]";
username.GivenName = "GivenName";
username.FamilyName = "FamilyName";
user.Name = username;
user.Password = "Password";
service.Users.Insert(user);
var group = new Group();
group.Email = "[email protected]";
group.Name = "GroupName";
service.Groups.Insert(group);
}