My reputation is not high enough to add a comment to clarify before posting a response, so I will have to make some assumptions here.
The first assumption is that you are using a service account to access the API.
The second assumption is that you have a certificate from the Google admin control panel and everything is fine.
I had a similar problem when I was updating user accounts via the API and it was found for me that the directory administrator account is a delegate for the service account.
Here is the code that I use to initialize my Google directory service.
private static DirectoryService initializeGoogleDirectoryService() { try { String serviceAccountEmail = "your_service_account_email@developer.gserviceaccount.com"; var certificate = new X509Certificate2(@"your_certificate_name.p12", "your_secret", X509KeyStorageFlags.Exportable); // For the service account to work, a user with admin privs must be assigned as the delegate. ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(serviceAccountEmail) { // Change the scope here to the one you need to modify org units. Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser }, User = "administrator_account@your_google_apps_domain.com" }.FromCertificate(certificate)); // Create the service. var service = new DirectoryService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = "Your_Application_Name" }); return service; } catch (Exception ex) { // Exception handling code below. return null; } finally { } }
sheppe
source share