You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
You can also download the Java SDK JAR and and its required dependencies directly from the[latest release page](https://github.com/dropbox/dropbox-sdk-java/releases/latest). Note that the distribution artifacts on the releases pages do not contain optional dependencies.
31
31
32
-
##Get aDropboxAPI key
32
+
##Dropboxfor Java tutorial
33
33
34
-
You need a Dropbox API key to make API requests.
35
-
* Go to:[https://www.dropbox.com/developers/apps](https://www.dropbox.com/developers/apps)
36
-
* If you've already registered an app, click on the "Options" link to see the app's API key and secret.
37
-
* Otherwise, click "Create an app" to register an app. Choose "Dropbox API app", then "Files and datastores", then "Yes" or "No"[depending on your needs](https://www.dropbox.com/developers/reference#permissions).
34
+
A good way to start using the Java SDK is to follow this quick tutorial. Just make sure you have the the Java SDK[installed](/developers/documentation/java#install) first!
38
35
39
-
Save the API key to a JSON file called, say, "test.app":
36
+
###Register a Dropbox APIapp
40
37
38
+
To use the Dropbox API, you'll need to register a new app in the[App Console](/developers/apps). Select Dropbox API app and choose your app's permission. You'll need to use the app key created with this app to access API v2.
39
+
40
+
###Link an account
41
+
42
+
In order to make calls to the API, you'll need an instance of the Dropbox object. To instantiate, pass in the access token for the account you want to link. (Tip: You can[generate an access token](https://blogs.dropbox.com/developers/2014/05/generate-an-access-token-for-your-own-account/) for your own account through the[App Console](https://www.dropbox.com/developers/apps)).
Before your appcanaccess a Dropbox user's files, the user must authorize your application using OAuth 2. Successfully completing this authorization flow gives you an_access token_ for the user's Dropbox account, which grants you the ability to make Dropbox API calls to access their files.
151
+
Some more complete examplescanbe found here:
51
152
* Example for a simple web app:[Web File Browser example](examples/web-file-browser/src/main/java/com/dropbox/core/examples/web_file_browser/DropboxAuth.java)
52
153
* Example for an Android app:[Android example](examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java)
53
154
* Example for a command-line tool:[Command-Line Authorization example](examples/authorize/src/main/java/com/dropbox/core/examples/authorize/Main.java)
54
155
55
-
Once you have an access token, create a[`DbxClientV2`](https://dropbox.github.io/dropbox-sdk-java/api-docs/v2.1.x/com/dropbox/core/v2/DbxClientV2.html) and start making API calls.
156
+
To try out running this examples, please follow the instructions below.
56
157
57
-
You only need to perform the authorization process once per user. Once you have an access token for a user, save it somewhere persistent, like in a database. The next time that user visits your app's, you can skip the authorization process and go straight to creating a`DbxClientV2` and making API calls.
158
+
###Save your Dropbox API key
159
+
160
+
Save your Dropbox API key to a JSON file called, say, "test.app":
1. Follow the instructions in the "Build from source" section above.
73
183
2. Save your Dropbox API key in a file called "test.app". See:[Get a Dropbox API key](#get-a-dropbox-api-key), above.
74
184
3. Compile and install the SDK into your local maven repo:`./gradlew install`
75
185
4. To compile all the examples:`(cd examples/ && ./gradlew classes`
76
186
5. To compile just one example:`(cd examples/ && ./gradlew :<example-name>:classes`
77
187
78
-
###authorize
188
+
####authorize
79
189
80
190
This examples runs through the OAuth 2 authorization flow.
81
191
@@ -86,7 +196,7 @@ cd examples
86
196
87
197
This produces a file named "test.auth" that has the access token. This file can be passed in to the other examples.
88
198
89
-
###account-info
199
+
####account-info
90
200
91
201
A simple example that fetches and displays information about the account associated with the access token.
92
202
@@ -97,7 +207,7 @@ cd examples
97
207
98
208
(You must first generate "test.auth" using the "authorize" example above.)
99
209
100
-
###longpoll
210
+
####longpoll
101
211
102
212
An example of how to watch for changes in a Dropbox directory.
103
213
@@ -108,11 +218,11 @@ cd examples
108
218
109
219
(You must first generate "test.auth" using the "authorize" example above.)
110
220
111
-
###tutorial
221
+
####tutorial
112
222
113
223
The example from our[online tutorial](https://www.dropbox.com/developers/documentation/java#tutorial). Unlike the other examples, this example is not meant to be run without modification.
114
224
115
-
###upload-file
225
+
####upload-file
116
226
117
227
Uploads a file to Dropbox. The example includes regular and chunked file uploads.
118
228
@@ -123,7 +233,7 @@ cd examples
123
233
124
234
(You must first generate "test.auth" using the "authorize" example above.)
125
235
126
-
###web-file-browser
236
+
####web-file-browser
127
237
128
238
A tiny web app that runs through the OAuth 2 authorization flow and then uses Dropbox API calls to let the user browse their Dropbox files.