Package com.dropbox.core.v2
Class DbxClientV2
java.lang.Object
com.dropbox.core.v2.DbxClientV2Base
com.dropbox.core.v2.DbxClientV2
Use this class to make remote calls to the Dropbox API user endpoints. User
endpoints expose actions you can perform as a Dropbox user. You'll need an
access token first, normally acquired by directing a Dropbox user through the
auth flow using
DbxWebAuth.
This class has no mutable state, so it's thread safe as long as you pass
in a thread safe HttpRequestor implementation.
-
Field Summary
Fields inherited from class com.dropbox.core.v2.DbxClientV2Base
_client -
Constructor Summary
ConstructorsConstructorDescriptionDbxClientV2(DbxRequestConfig requestConfig, DbxCredential credential) Create a client that usesDbxCredentialinstead of raw access token.DbxClientV2(DbxRequestConfig requestConfig, String accessToken) Creates a client that uses the given OAuth 2 access token as authorization when performing requests against the default Dropbox hosts.DbxClientV2(DbxRequestConfig requestConfig, String accessToken, DbxHost host) Same asDbxClientV2(DbxRequestConfig, String)except you can also set the hostnames of the Dropbox API servers.DbxClientV2(DbxRequestConfig requestConfig, String accessToken, DbxHost host, String userId) Same asDbxClientV2(DbxRequestConfig, String, DbxHost)except you can also set the userId for multiple Dropbox accounts.DbxClientV2(DbxRequestConfig requestConfig, String accessToken, String userId) Creates a client that uses the given OAuth 2 access token as authorization when performing requests against the default Dropbox hosts. -
Method Summary
Modifier and TypeMethodDescriptionRefresh the access token insideDbxCredential.withPathRoot(PathRoot pathRoot) Returns a newDbxClientV2that performs requests against Dropbox API user endpoints relative to a namespace without including the namespace as part of the path variable for every request.Methods inherited from class com.dropbox.core.v2.DbxClientV2Base
account, auth, check, contacts, fileProperties, fileRequests, files, openid, paper, riviera, sharing, users
-
Constructor Details
-
DbxClientV2
Creates a client that uses the given OAuth 2 access token as authorization when performing requests against the default Dropbox hosts.- Parameters:
requestConfig- Default attributes to use for each requestaccessToken- OAuth 2 access token (that you got from Dropbox) that gives your app the ability to make Dropbox API calls. Typically acquired throughDbxWebAuth
-
DbxClientV2
Creates a client that uses the given OAuth 2 access token as authorization when performing requests against the default Dropbox hosts.- Parameters:
requestConfig- Default attributes to use for each requestaccessToken- OAuth 2 access token (that you got from Dropbox) that gives your app the ability to make Dropbox API calls. Typically acquired throughDbxWebAuthuserId- The user ID of the current Dropbox account. Used for multi-Dropbox account use-case.
-
DbxClientV2
Create a client that usesDbxCredentialinstead of raw access token. The credential object include access token as well as refresh token, expiration time, app key and app secret. Using credential enables dropbox client to support short live token feature.- Parameters:
requestConfig- Default attributes to use for each requestcredential- The credential object containing all the information for authentication.
-
DbxClientV2
Same asDbxClientV2(DbxRequestConfig, String)except you can also set the hostnames of the Dropbox API servers. This is used in testing. You don't normally need to call this.- Parameters:
requestConfig- Default attributes to use for each requestaccessToken- OAuth 2 access token (that you got from Dropbox) that gives your app the ability to make Dropbox API calls. Typically acquired throughDbxWebAuthhost- Dropbox hosts to send requests to (used for mocking and testing)
-
DbxClientV2
Same asDbxClientV2(DbxRequestConfig, String, DbxHost)except you can also set the userId for multiple Dropbox accounts.- Parameters:
requestConfig- Default attributes to use for each requestaccessToken- OAuth 2 access token (that you got from Dropbox) that gives your app the ability to make Dropbox API calls. Typically acquired throughDbxWebAuthhost- Dropbox hosts to send requests to (used for mocking and testing)userId- The user ID of the current Dropbox account. Used for multi-Dropbox account use-case.
-
-
Method Details
-
withPathRoot
Returns a newDbxClientV2that performs requests against Dropbox API user endpoints relative to a namespace without including the namespace as part of the path variable for every request. (https://www.dropbox.com/developers/reference/namespace-guide#pathrootmodes).This method performs no validation of the namespace ID.
- Parameters:
pathRoot- the path root for this client, nevernull.- Returns:
- Dropbox client that issues requests with Dropbox-API-Path-Root header.
- Throws:
IllegalArgumentException- IfpathRootisnull
-
refreshAccessToken
Refresh the access token insideDbxCredential. It has the same behavior asDbxCredential.refresh(DbxRequestConfig).- Returns:
- The result contains new short-live access token and expiration time.
- Throws:
DbxOAuthException- If refresh failed because of invalid parameter or invalid refresh token.DbxException- If refresh failed before of general problems like network issue.
-