title: Can't list users with Google Directory API Admin SDK
body: <p>I'm trying to use the <a href="https://developers.google.com/admin-sdk/directory/v1/guides/manage-users" rel="nofollow noreferrer">AdminService</a> to manage my domain's users and groups, but I'm stuck with a simple request to get all the users of my domain. There is the code in C#:</p>
  
  <pre><code>public Users GetAllUsers()
  {
      var provider = new AssertionFlowClient(
          GoogleAuthenticationServer.Description,
          new X509Certificate2(privateKeyPath, keyPassword, X509KeyStorageFlags.Exportable))
      {
          ServiceAccountId = serviceAccountEmail,
          Scope = AdminService.Scopes.AdminDirectoryUser.GetStringValue()
      };
  
      var auth = new OAuth2Authenticator&lt;AssertionFlowClient&gt;(provider, AssertionFlowClient.GetState);
  
      m_serviceGroup = new AdminService(new BaseClientService.Initializer()
      {
          Authenticator = auth,
      });
  
      var request = m_serviceUser.Users.List();
      request.Domain = m_domainName;
      return request.Fetch();
  }
  </code></pre>
  
  <p>I'm getting an exception when Fetch() that says:</p>
  
  <pre><code>Code: 403    
  Message: Not Authorized to access this resource/api 
  Error: {Message[Not Authorized to access this resource/api] Location[ - ] Reason[forbidden] Domain[global]}
  </code></pre>
  
  <p>I've followed the instructions <a href="http://support.google.com/a/bin/answer.py?hl=en&amp;answer=60757" rel="nofollow noreferrer">here</a> to have enabled API access, and also authorized my service account in domain control panel:</p>
  
  <pre><code>[Security]-&gt;[Advanced Setting]-&gt;[Authentication]-&gt;[Manage third party OAuth Client access]
  </code></pre>
  
  <p>with scopes:</p>
  
  <pre><code>https://www.googleapis.com/auth/admin.directory.group 
  https://www.googleapis.com/auth/admin.directory.user
  </code></pre>
  
  <p>Admin SDK Service is also enabled in API control panel.</p>
  
  <p>I tried the code to use the DriveService and successfully listed/created/deleted files without any problem, so the authentication part of the code should be alright. I couldn't figure out what else needs to be configured or if there is any other problems with my code.</p>
  
  <p>Thanks for any help.</p>