title: New to C#. How to use google-admin-sdk (add users, add user to group a.s.o.)?
body: <p>Trying to get the hang of how to use google-admin-sdk in C# (got a possible job-opening)</p>
  
  <p>I've managed to create code for creating users and adding a user to a group in Python 2.7 as commandline-tools.</p>
  
  <p>But the employer asked med if I could do the same in C#. I think I would get the hang of it, but would appreciate some help on how to start.
  I have installed  Visual Studio Express 2012 for Desktop and downloaded:
      google-admin-directory_v1-rev6-csharpp-1.4.0-beta.zip
      google-api-dotnet-client-1.4.0-beta-samples.zip
      google-api-dotnet-client-1.4.0-beta.zip</p>
  
  <p>But I can't find any (for me understandble) samples. </p>
  
  <p>Any one care to give me any good pointers? Would be very much appreciated. :)
  /Jonas</p>
  
  <p>Edit : Adding my code so far!</p>
  
  <pre><code>using System;
  using System.Diagnostics;
  using System.Linq;
  
  using DotNetOpenAuth.OAuth2;
  
  using Google.Apis.Authentication.OAuth2;
  using Google.Apis.Authentication.OAuth2.DotNetOpenAuth;
  using Google.Apis.Samples.Helper;
  using Google.Apis.Services;
  using Google.Apis.Util;
  using Google.Apis.Admin.directory_v1;
  using Google.Apis.Admin.directory_v1.Data;
  
  
  
  namespace Bergstedts.ListUsers
  {
      public class Program    
      {
          static void Main(string[] args)
          {
               // Display the header and initialize the sample.
              CommandLine.EnableExceptionHandling();
              CommandLine.DisplayGoogleSampleHeader("Lists all Users");
  
              // Register the authenticator.
              var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description)
                  {
                      ClientIdentifier = "my ID",
                      ClientSecret = "my secret"
                  };
  
              var auth = new OAuth2Authenticator&lt;NativeApplicationClient&gt;(provider, GetAuthorization);
  
              // Create the service.
              var service = new DirectoryService(new BaseClientService.Initializer()
                  {
                      Authenticator = auth,
                      ApplicationName = "List Users",
  
                  });
  
              service.Users.List().Domain = "mydomain.com";
              Users results = service.Users.List().Execute();
              Console.WriteLine("Users:");
              foreach (User list in results.UsersValue)
              {
                  Console.WriteLine("- " + list.Name);
              }
              Console.ReadKey();
          }
  
          private static IAuthorizationState GetAuthorization(NativeApplicationClient arg)
          {
              // Get the auth URL:
              IAuthorizationState state = new AuthorizationState(new[] { DirectoryService.Scopes.AdminDirectoryUser.GetStringValue() });
              state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
              Uri authUri = arg.RequestUserAuthorization(state);
  
              // Request authorization from the user (by opening a browser window):
              Process.Start(authUri.ToString());
              Console.Write("  Authorization Code: ");
              string authCode = Console.ReadLine();
              Console.WriteLine();
  
              // Retrieve the access token by using the authorization code:
              return arg.ProcessUserAuthorization(authCode, state);
          }
  
      }
  }
  </code></pre>
  
  <p>Edit : Found how to add the domain :</p>
  
  <pre><code>service.Users.List().Domain = "mydomain.com";
  </code></pre>
  
  <p>But I still get the same error message :
       An error has occured:
          Google.Apis.Requests.RequestError
      Bad Request [400]
      Errors [ 
              Message[Bad Request] Location[ - ] Reason[badRequest] Domain[global]
      ]</p>