/** * Get information about a user's account. * * @param accountId A user's account identifier. Must have length of at * least 40, have length of at most 40, and not be {@code null}. * * @return Basic information about any account. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ public BasicAccount getAccount(String accountId) throws GetAccountErrorException, DbxException { GetAccountArg _arg = new GetAccountArg(accountId); return getAccount(_arg); }
/** * Get information about multiple user accounts. At most 300 accounts may * be queried per request. * * @param accountIds List of user account identifiers. Should not contain * any duplicate account IDs. Must contain at least 1 items, not contain * a {@code null} item, and not be {@code null}. * * @throws IllegalArgumentException If any argument does not meet its * preconditions. */ public List<BasicAccount> getAccountBatch(List<String> accountIds) throws GetAccountBatchErrorException, DbxException { GetAccountBatchArg _arg = new GetAccountBatchArg(accountIds); return getAccountBatch(_arg); }
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(); } catch (DbxException e) { builder.error(ResultErrorBuilder .withCodeAndDescription(VerificationError.StandardCode.AUTHENTICATION, "Invalid client identifier and/or access token") .parameterKey("accessToken").parameterKey("clientIdentifier").build()); } }
@Override public Space get() throws BackgroundException { try { final SpaceUsage usage = new DbxUserUsersRequests(session.getClient()).getSpaceUsage(); final SpaceAllocation allocation = usage.getAllocation(); if(allocation.isIndividual()) { return new Space(usage.getUsed(), allocation.getIndividualValue().getAllocated()); } else if(allocation.isTeam()) { return new Space(usage.getUsed(), allocation.getTeamValue().getAllocated()); } return new Space(0L, Long.MAX_VALUE); } catch(DbxException e) { throw new DropboxExceptionMappingService().map("Failure to read attributes of {0}", e, new Path(String.valueOf(Path.DELIMITER), EnumSet.of(Path.Type.volume, Path.Type.directory))); } } }
/** * For internal use only. * * @param _client Raw v2 client to use for issuing requests */ protected DbxClientV2Base(DbxRawClientV2 _client) { this._client = _client; this.auth = new DbxUserAuthRequests(_client); this.contacts = new DbxUserContactsRequests(_client); this.fileProperties = new DbxUserFilePropertiesRequests(_client); this.fileRequests = new DbxUserFileRequestsRequests(_client); this.files = new DbxUserFilesRequests(_client); this.paper = new DbxUserPaperRequests(_client); this.sharing = new DbxUserSharingRequests(_client); this.users = new DbxUserUsersRequests(_client); }
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()); } }
private void displayCloudStatus() { String message = "Working locally."; String displayName; // Check Dropbox connection DbxClientV2 client = DbxUtil.getDbxClient(); if (client != null) { try { displayName = client.users().getCurrentAccount().getName().getDisplayName(); message = "Connected to Dropbox account as " + displayName + "."; Cloud.getInstance().setStatus(Cloud.Status.DBX_CONNECTED, " (" + displayName + ")"); } catch (DbxException ex) { // simply stay working locally. Cloud.getInstance().setStatus(Cloud.Status.DISCONNECTED); } } LOGGER.log(message); }
String additional = ""; if(client != null) { additional = " (" + client.users().getCurrentAccount().getName().getDisplayName() + ")";