2014-07-25 2 views

답변

0

첫 번째 단계는 도메인 전체 위임 권한이있는 서비스 계정을 갖는 것입니다. 아래 링크는 물론

String serviceAccountEmail = "[email protected]"; 
X509Certificate2 certificate = new X509Certificate2(@"C:\key.p12", "notasecret", X509KeyStorageFlags.Exportable); 
ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail) 
       { 
        Scopes = new[] 
        { 
         DirectoryService.Scope.AdminDirectoryUser 
        }, 
        User = "[email protected]" 
       }.FromCertificate(certificate)); 

       var ser = new DirectoryService(new BaseClientService.Initializer() 
       { 
        HttpClientInitializer = credential, 
        ApplicationName = "Get it to work", 
       }); 

       User newuserbody = new User(); 
       UserName newusername = new UserName(); 
       newuserbody.PrimaryEmail = "[email protected]"; 
       newusername.GivenName = "jack"; 
       newusername.FamilyName = "black"; 
       newuserbody.Name = newusername; 
       newuserbody.Password = "password"; 

       User results = ser.Users.Insert(newuserbody).Execute(); 
작동 "OAuth 클라이언트 액세스 관리" https://developers.google.com/admin-sdk/directory/v1/guides/delegation

그것은 고급 설정에서 "관리 타사 OAuth 클라이언트 액세스"에 서비스 계정을 추가하는 말을하지만 난했다하는 방법을 보여줍니다