title: Google Drive credentials
body: <p>I am creating a app where in i have to store files in Google drive of the user logged in , so which ever user logged in he can store data on his drive. Now i have a problem how to generate  Google Drive credentials (clientId, clientSecret and refreshToken) from code , as all the example i see ,ask as to go to Google console and do that.Is there any we can achieve it using java code. Actually i need to use google drive ad database storage.
  Used the below code : but that need the Client id.</p>
  
  <pre><code>    public class Main
  {
    public static void main(String[] args)
    {
      String clientId = "...";
      String clientSecret = "...";
  
      HttpTransport httpTransport = new NetHttpTransport();
      JsonFactory jsonFactory = new JacksonFactory();
  
      GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
        httpTransport, 
        jsonFactory,
        clientId,
        clientSecret,
        Arrays.asList(DriveScopes.DRIVE)
      )
        .setAccessType("online")
        .setApprovalPrompt("auto").build();
  
      String redirectUri = "urn:ietf:wg:oauth:2.0:oob";     
      String url = 
        flow
          .newAuthorizationUrl()
          .setRedirectUri(redirectUri)
          .build();
  
      System.out.println("Please open the following URL in your browser then type the authorization code:");
      System.out.println("  " + url);
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String code = br.readLine();
  
      GoogleTokenResponse response = 
        flow
          .newTokenRequest(code)
          .setRedirectUri(redirectUri)
          .execute();
  
      GoogleCredential credential = 
        new GoogleCredential()
          .setFromTokenResponse(response);
  
      Drive service = 
        new Drive.Builder(httpTransport, jsonFactory, credential)
          .build();
  
      ...
    }
  }
  </code></pre>