title: Error when getting groups for a particular email ID with Java google apps directory API
body: <p>I want to get groups for a particular email ID in Google Apps with the help of the Java Google Apps Directory API but I am getting an error.</p>
  
  <p>Can someone help explain what the error is and what in my code might be causing it? The error and related code follows.</p>
  
  <p><strong>Error:</strong></p>
  
  <pre><code>WARNING: Application name is not set. Call Builder#setApplicationName.
  Exception in thread "main" com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
  {
    "error" : "invalid_grant"
  }
  </code></pre>
  
  <hr>
  
  <pre><code>import java.util.ArrayList;
  import java.util.Collection;
  import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
  import com.google.api.client.http.HttpTransport;
  import com.google.api.client.http.javanet.NetHttpTransport;
  import com.google.api.client.json.jackson2.JacksonFactory;
  import com.google.api.services.admin.directory.Directory;
  import com.google.api.services.admin.directory.model.Group;
  import com.google.api.services.bigquery.Bigquery;
  
  public class Test {
      private static Bigquery bigquery;  
      /**
       * @param args
       */
  
      public static void main(String[] args) throws Exception{
          // TODO Auto-generated method stub
  
          HttpTransport httpTransport = new NetHttpTransport();
          JacksonFactory jsonFactory = new JacksonFactory();
  
          Collection&lt;String&gt; SCOPES = new ArrayList&lt;String&gt;();
          SCOPES.add("https://www.googleapis.com/auth/admin.directory.group");
          SCOPES.add("https://www.googleapis.com/auth/admin.directory.user");
  
  
          GoogleCredential credential =  new GoogleCredential.Builder()
              .setTransport(httpTransport)
              .setJsonFactory(jsonFactory)
              .setServiceAccountId("244204474315-l08ah6g350oofeosi7p8pqmotlrmgion.apps.googleusercontent.com")
              .setServiceAccountUser("244204474315-l08ah6g350oofeosi7p8pqmotlrmgion@developer.gserviceaccount.com")
              .setServiceAccountScopes(SCOPES)
              .setServiceAccountPrivateKeyFromP12File(
                      new java.io.File("C:\\Users\\nbaser\\Desktop\\76ba0ac39b06e8419bbb670734f3b2affeec43b2-privatekey.p12"))
              .build();
  
  
          Directory directory = new Directory.Builder(httpTransport, jsonFactory, credential).build();
  
  //      Directory.Users.List list = directory.users().list();
  //      list.setDomain("yourDomain.com");
  //      Users users = list.execute();
  
  
          //Directory.Users.Get user = directory.users().get("nishant.baser@ahold.com");
          //user.get
  
          Directory.Groups.Get group = directory.groups().get("ausa.googleams.group@ahold.com");
          Group groups = group.execute();
  
  //      Directory.Members.List list = directory.members().list("ausa.googleams.group@ahold.com");
  
  //      Members members = list.execute();
  
  //      System.out.println(members);
      }
  
  }
  </code></pre>