title: File upload using google drive api
body: <p>I want to upload file to my google drive.I have code for insert files to google drive but its get request url from google authentication.I don't want this implementation.I want upload file directly google drive using java.</p>
  
  <p>My java code is :</p>
  
  <pre><code>       `HttpTransport httpTransport = new NetHttpTransport();
          JsonFactory jsonFactory = new JacksonFactory();
  
          GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(httpTransport, jsonFactory, IRingeeConstants.GOOGLE_DRIVE_CLIENT_ID, IRingeeConstants.GOOGLE_DRIVE_SCRET,
                  Arrays.asList(DriveScopes.DRIVE)).setAccessType("online").setApprovalPrompt("auto").build();
  
          String url = flow.newAuthorizationUrl().setRedirectUri(REDIRECT_URI).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(REDIRECT_URI).execute();
          GoogleCredential credential = new GoogleCredential().setFromTokenResponse(response);
  
          // Create a new authorized API client
          Drive service = new Drive.Builder(httpTransport, jsonFactory, credential).build();
  
          // Insert a file
          File body = new File();
          body.setTitle("Ringee document");
          body.setDescription("A test document");
          body.setMimeType("text/plain");
  
          java.io.File fileContent = new java.io.File("G:\\document.txt");
          FileContent mediaContent = new FileContent("text/plain", fileContent);
  
          File file = service.files().insert(body, mediaContent).execute();
          System.out.println("File ID: " + file.getId());`
  </code></pre>
  
  <p>I want direct upload not required any permission for insert and accessing files from google drive.</p>