use of com.dropbox.core.v2.users.FullAccount in project dropbox-sdk-java by dropbox.
the class Main method testBasicSerialization.
private static void testBasicSerialization(DbxClientV2 client) throws DbxException, IOException {
// Make the /account/info API call.
FullAccount expected = client.users().getCurrentAccount();
assertNotNull(expected);
String accountId = expected.getAccountId();
assertNotNull(accountId);
assertNotNull(expected.getName());
BasicAccount actual = client.users().getAccount(accountId);
assertNotNull(actual);
assertEquals(actual.getAccountId(), expected.getAccountId());
assertEquals(actual.getEmail(), expected.getEmail());
}
use of com.dropbox.core.v2.users.FullAccount in project dropbox-sdk-java by dropbox.
the class Main method main.
public static void main(String[] args) throws IOException {
// Only display important log messages.
Logger.getLogger("").setLevel(Level.WARNING);
if (args.length != 1) {
System.out.println("");
System.out.println("Usage: COMMAND <auth-file>");
System.out.println("");
System.out.println(" <auth-file>: An \"auth file\" that contains the information necessary to make");
System.out.println(" an authorized Dropbox API request. Generate this file using the \"authorize\"");
System.out.println(" example program.");
System.out.println("");
System.exit(1);
return;
}
String argAuthFile = args[0];
// 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.
DbxRequestConfig requestConfig = new DbxRequestConfig("examples-account-info");
DbxClientV2 dbxClient = new DbxClientV2(requestConfig, authInfo.getAccessToken(), authInfo.getHost());
// Make the /account/info API call.
FullAccount dbxAccountInfo;
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());
}
use of com.dropbox.core.v2.users.FullAccount in project dropbox-sdk-java by dropbox.
the class DbxClientV2IT method testAccountInfo.
@Test
public void testAccountInfo() throws Exception {
DbxClientV2 client = ITUtil.newClientV2();
FullAccount full = client.users().getCurrentAccount();
assertNotNull(full);
assertNotNull(full.getName());
assertNotNull(full.getAccountId());
BasicAccount basic = client.users().getAccount(full.getAccountId());
assertNotNull(basic);
assertNotNull(basic.getName());
assertEquals(basic.getAccountId(), full.getAccountId());
}
use of com.dropbox.core.v2.users.FullAccount in project dropbox-sdk-java by dropbox.
the class Main method main.
public static void main(String[] args) throws DbxException, IOException {
// Create Dropbox client
DbxRequestConfig config = new DbxRequestConfig("dropbox/java-tutorial");
DbxClientV2 client = new DbxClientV2(config, ACCESS_TOKEN);
// Get current account info
FullAccount account = client.users().getCurrentAccount();
System.out.println(account.getName().getDisplayName());
// Get files and folder metadata from Dropbox root directory
ListFolderResult result = client.files().listFolder("");
while (true) {
for (Metadata metadata : result.getEntries()) {
System.out.println(metadata.getPathLower());
}
if (!result.getHasMore()) {
break;
}
result = client.files().listFolderContinue(result.getCursor());
}
// Upload "test.txt" to Dropbox
try (InputStream in = new FileInputStream("test.txt")) {
FileMetadata metadata = client.files().uploadBuilder("/test.txt").uploadAndFinish(in);
}
}
Aggregations