title: how to authenticated google service account to call youtube API to generate token in java
body: <p>I m developing web application for getting particular youtube video detail.for this i did the code like call authorization process using google service account.i thought authentication is done and its not generating the token.while i run my code it getting error like "INVALID_GRANT".Please help me to resolve this.</p>
  
  <pre><code>        here my sample code is as:
  
      String clientId = "Something.apps.googleusercontent.com";
                  @SuppressWarnings({ "unchecked", "rawtypes" })
                  List&lt;String&gt;scops = new &lt;String&gt;ArrayList();
                  scops.add("https://www.googleapis.com/auth/youtubepartner");
                  final HttpTransport TRANSPORT = new NetHttpTransport();
                  final JsonFactory JSON_FACTORY = new JacksonFactory();
  
                  GoogleCredential credential = new GoogleCredential.Builder()
                  .setTransport(TRANSPORT)
                  .setJsonFactory(JSON_FACTORY)
                  .setServiceAccountId(clientId)
                  .setServiceAccountScopes(scops)
                  .setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
                  .build();
                  System.out.println("credential............."+credential);
                  YouTube youtube=new YouTube.Builder(TRANSPORT, JSON_FACTORY, credential).setApplicationName("test").build();
                  System.out.println("Responce.............."+youtube);
                  com.google.api.services.youtube.YouTube.Activities act=youtube.activities();
                  com.google.api.services.youtube.YouTube.Activities.List list=act.list("");
                  list.execute();
                  System.out.println("list Details...................."+list);
  
      here i passes Youtube Api to retrieving the list.
  
      error :
  
      Exceptioncom.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
      {
        "error" : "invalid_grant"
      }
  
      i m waiting for all of ur response to resolve this problem..Thanks all once again to spend time with my pro
  </code></pre>