use of com.dropbox.core.v2.DbxClientV2 in project orgzly-android by orgzly.
the class DropboxClient method getDbxClient.
private DbxClientV2 getDbxClient(String accessToken) {
String userLocale = Locale.getDefault().toString();
String clientId = String.format("%s/%s", BuildConfig.APPLICATION_ID, BuildConfig.VERSION_NAME);
DbxRequestConfig requestConfig = DbxRequestConfig.newBuilder(clientId).withUserLocale(userLocale).build();
return new DbxClientV2(requestConfig, accessToken);
}
use of com.dropbox.core.v2.DbxClientV2 in project keepass2android by PhilippC.
the class DropboxV2Storage method buildSession.
private void buildSession() {
String v2Token = getKeyV2();
if (v2Token != null) {
dbxClient = new DbxClientV2(requestConfig, v2Token);
setLoggedIn(true);
Log.d(TAG, "Creating Dropbox Session with accessToken");
} else {
setLoggedIn(false);
Log.d(TAG, "Creating Dropbox Session without accessToken");
}
}
use of com.dropbox.core.v2.DbxClientV2 in project syndesis by syndesisio.
the class DropBoxVerifierExtension method verifyCredentials.
@SuppressWarnings("PMD.AvoidCatchingGenericException")
private void verifyCredentials(ResultBuilder builder, Map<String, Object> parameters) {
String token = (String) parameters.get("accessToken");
String clientId = (String) parameters.get("clientIdentifier");
try {
// Create Dropbox client
DbxRequestConfig config = new DbxRequestConfig(clientId, Locale.getDefault().toString());
DbxClientV2 client = new DbxClientV2(config, token);
client.users().getCurrentAccount();
client = null;
} catch (Exception e) {
builder.error(ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, "Invalid client identifier and/or access token").parameterKey("accessToken").parameterKey("clientIdentifier").build());
}
}
use of com.dropbox.core.v2.DbxClientV2 in project jbpm-work-items by kiegroup.
the class DropboxAuth method authorize.
public DbxClientV2 authorize(String clientIdentifier, String accessToken) throws IllegalArgumentException {
try {
DbxRequestConfig config = new DbxRequestConfig(clientIdentifier);
DbxClientV2 client = new DbxClientV2(config, accessToken);
return client;
} catch (Exception e) {
throw new IllegalArgumentException(e.getMessage());
}
}
use of com.dropbox.core.v2.DbxClientV2 in project dropbox-sdk-java by dropbox.
the class Main method printChanges.
/**
* Prints changes made to a folder in Dropbox since the given
* cursor was retrieved.
*
* @param dbxClient Dropbox client to use for fetching folder changes
* @param cursor lastest cursor received since last set of changes
*
* @return latest cursor after changes
*/
private static String printChanges(DbxClientV2 client, String cursor) throws DbxApiException, DbxException {
while (true) {
ListFolderResult result = client.files().listFolderContinue(cursor);
for (Metadata metadata : result.getEntries()) {
String type;
String details;
if (metadata instanceof FileMetadata) {
FileMetadata fileMetadata = (FileMetadata) metadata;
type = "file";
details = "(rev=" + fileMetadata.getRev() + ")";
} else if (metadata instanceof FolderMetadata) {
FolderMetadata folderMetadata = (FolderMetadata) metadata;
type = "folder";
details = folderMetadata.getSharingInfo() != null ? "(shared)" : "";
} else if (metadata instanceof DeletedMetadata) {
type = "deleted";
details = "";
} else {
throw new IllegalStateException("Unrecognized metadata type: " + metadata.getClass());
}
System.out.printf("\t%10s %24s \"%s\"\n", type, details, metadata.getPathLower());
}
// update cursor to fetch remaining results
cursor = result.getCursor();
if (!result.getHasMore()) {
break;
}
}
return cursor;
}
Aggregations