예제 #1
0
  public static void main(String[] args) throws IOException {
    // Only display important log messages.
    Logger.getLogger("").setLevel(Level.WARNING);

    String argAuthFile = "token.auth";

    // Read auth info file.
    DbxAuthInfo authInfo;
    try {
      authInfo = DbxAuthInfo.Reader.readFromFile(argAuthFile);
    } catch (JsonReader.FileLoadException ex) {
      System.err.println("Error loading <auth-file>: " + ex.getMessage());
      System.exit(1);
      return;
    }

    // Create a DbxClientV1, which is what you use to make API calls.
    String userLocale = Locale.getDefault().toString();
    DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info", userLocale);
    DbxClientV2 dbxClient = new DbxClientV2(requestConfig, authInfo.accessToken, authInfo.host);

    // Make the /account/info API call.
    DbxUsers.FullAccount dbxAccountInfo;
    DbxUsers.SpaceUsage dbxSpaceUsage;
    try {
      dbxAccountInfo = dbxClient.users.getCurrentAccount();
    } catch (DbxException ex) {
      System.err.println("Error making API call: " + ex.getMessage());
      System.exit(1);
      return;
    }

    System.out.print(dbxAccountInfo.toStringMultiline());
  }