title: How to get the auth token for dropbox directly into java program so that user don't need to copy paste it
body: <p>I am developing an application where I have to upload file and download file from dropbox account, application is a java desktop application. I have used the sample code and was able to run it without any glitch. But I want to bypass that user needs to copy the auth code form browser to the application, how can be that done. I want my application to get the auth token directly into the application, because this is causing overhead on user.
  All the experts please help me.
  Here's the code I have Implemented.</p>
  
  <pre><code>import com.dropbox.core.*;
  
  import java.awt.Desktop;
  import java.io.*;
  import java.util.Locale;
  
  public class Main {
  public static void main(String[] args) throws IOException, DbxException {
      // Get your app key and secret from the Dropbox developers website.
      final String APP_KEY = "xxxxxxxxxxxxxxxx";
      final String APP_SECRET = "xxxxxxxxxxxxxxxx";
  
      DbxAppInfo appInfo = new DbxAppInfo(APP_KEY, APP_SECRET);
  
      DbxRequestConfig config = new DbxRequestConfig("JavaTutorial/1.0",
          Locale.getDefault().toString());
      DbxWebAuthNoRedirect webAuth = new DbxWebAuthNoRedirect(config, appInfo);
  
      // Have the user sign in and authorize your app.
      String authorizeUrl = webAuth.start();
      System.out.println("1. Go to: " + authorizeUrl);
      System.out.println("2. Click \"Allow\" (you might have to log in first)");
      System.out.println("3. Copy the authorization code.");
      Desktop.getDesktop().browse(java.net.URI.create(authorizeUrl));
      String code = new BufferedReader(new InputStreamReader(System.in)).readLine().trim();
  
      // This will fail if the user enters an invalid authorization code.
      DbxAuthFinish authFinish = webAuth.finish(code);
  
      DbxClient client = new DbxClient(config, authFinish.accessToken);
  
      System.out.println("Linked account: " + client.getAccountInfo().displayName);
  
      File inputFile = new File("OpenCv_Video_display_link.txt");
      FileInputStream inputStream = new FileInputStream(inputFile);
      try {
          DbxEntry.File uploadedFile = client.uploadFile("/OpenCv_Video_display_link.txt",
              DbxWriteMode.add(), inputFile.length(), inputStream);
          System.out.println("Uploaded: " + uploadedFile.toString());
      } finally {
          inputStream.close();
      }
  
      DbxEntry.WithChildren listing = client.getMetadataWithChildren("/");
      System.out.println("Files in the root path:");
      for (DbxEntry child : listing.children) {
          System.out.println("    " + child.name + ": " + child.toString());
      }
  
      FileOutputStream outputStream = new FileOutputStream("121verbs.pdf");
      try {
          DbxEntry.File downloadedFile = client.getFile("/121verbs.pdf", null,
              outputStream);
          System.out.println("Metadata: " + downloadedFile.toString());
      } finally {
          outputStream.close();
      }
  }
  }
  </code></pre>