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
Copy file name to clipboardExpand all lines: README.md
+18-5Lines changed: 18 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,16 @@
1
1
Box Java SDK
2
2
============
3
3
4
-
This SDK provides a Java interface for the [Box REST API](https://developers.box.com/docs/). Features from the [previous version of the Box Java SDK](https://github.com/box/box-java-sdk-v2) are being transitioned to this SDK.
4
+
This SDK provides a Java interface for the [Box REST
5
+
API](https://developers.box.com/docs/). Features from the [previous version of
6
+
the Box Java SDK](https://github.com/box/box-java-sdk-v2) are being transitioned
7
+
to this SDK.
5
8
6
9
Quickstart
7
10
----------
8
11
9
-
Here is a simple example of how to authenticate with the API using a developer token and then print the ID and name of each item in your root folder.
12
+
Here is a simple example of how to authenticate with the API using a developer
13
+
token and then print the ID and name of each item in your root folder.
10
14
11
15
```java
12
16
BoxAPIConnection api =newBoxAPIConnection("developer-token");
@@ -20,13 +24,19 @@ for (BoxItem item : rootFolder) {
20
24
Building
21
25
--------
22
26
23
-
The SDK uses Gradle for its build system. Running `gradle build` from the root of the repository will compile, lint, and test the SDK.
27
+
The SDK uses Gradle for its build system. Running `gradle build` from the root
28
+
of the repository will compile, lint, and test the SDK.
24
29
25
30
```bash
26
31
$ gradle build
27
32
```
28
33
29
-
The SDK also includes integration tests which make real API calls, and therefore are run separately from unit tests. Integration tests should be run against a test account since they create and delete data. To run the integration tests, remove the `.template` extension from `src/test/config/config.properties.template` and fill in your test account's information. Then run:
34
+
The SDK also includes integration tests which make real API calls, and therefore
35
+
are run separately from unit tests. Integration tests should be run against a
36
+
test account since they create and delete data. To run the integration tests,
37
+
remove the `.template` extension from
38
+
`src/test/config/config.properties.template` and fill in your test account's
39
+
information. Then run:
30
40
31
41
```bash
32
42
$ gradle integrationTest
@@ -41,4 +51,7 @@ You can find guides and tutorials in the `doc` directory.
41
51
*[Authentication](doc/authentication.md)
42
52
*[Events Stream](doc/events.md)
43
53
44
-
Javadocs are also generated when `gradle build` is run and can be found in `build/doc/javadoc`.
54
+
Javadoc reference documentation is [available here][1]. Javadocs are also
55
+
generated when `gradle javadoc` is run and can be found in `build/doc/javadoc`.
Copy file name to clipboardExpand all lines: doc/authentication.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,21 @@
1
1
Authentication
2
2
==============
3
3
4
-
The Box API uses OAuth2 for authentication, which can be difficult to implement. The SDK makes it easier by providing classes that handle obtaining tokens and automatically refreshing them.
4
+
The Box API uses OAuth2 for authentication, which can be difficult to implement.
5
+
The SDK makes it easier by providing classes that handle obtaining tokens and
6
+
automatically refreshing them.
5
7
6
8
Ways to Authenticate
7
9
--------------------
8
10
9
11
### Developer Tokens
10
12
11
-
The fastest way to get started using the API is with developer tokens. A developer token is simply a short-lived access token that cannot be refreshed and can only be used with your own account. Therefore, they're only useful for testing an app and aren't suitable for production. You can obtain a developer token from your application's [developer console](https://cloud.app.box.com/developers/services).
13
+
The fastest way to get started using the API is with developer tokens. A
14
+
developer token is simply a short-lived access token that cannot be refreshed
15
+
and can only be used with your own account. Therefore, they're only useful for
16
+
testing an app and aren't suitable for production. You can obtain a developer
The following example creates an API connection with a developer token:
14
21
@@ -18,17 +25,24 @@ BoxAPIConnection api = new BoxAPIConnection("YOUR-DEVELOPER-TOKEN");
18
25
19
26
### Normal Authentication
20
27
21
-
Using an auth code is the most common way of authenticating with the Box API. Your application must provide a way for the user to login to Box (usually with a browser or web view) in order to obtain an auth code.
28
+
Using an auth code is the most common way of authenticating with the Box API.
29
+
Your application must provide a way for the user to login to Box (usually with a
30
+
browser or web view) in order to obtain an auth code.
22
31
23
-
After a user logs in and grants your application access to their Box account, they will be redirected to your application's `redirect_uri` which will contain an auth code. This auth code can then be used along with your client ID and client secret to establish an API connection.
32
+
After a user logs in and grants your application access to their Box account,
33
+
they will be redirected to your application's `redirect_uri` which will contain
34
+
an auth code. This auth code can then be used along with your client ID and
35
+
client secret to establish an API connection.
24
36
25
37
```java
26
38
BoxAPIConnection api =newBoxAPIConnection("YOUR-CLIENT-ID", "YOUR-CLIENT-SECRET", "YOUR-AUTH-CODE");
27
39
```
28
40
29
41
### Manual Authentication
30
42
31
-
In certain advanced scenarios, you may want to obtain an access and refresh token yourself through manual calls to the API. In this case, you can create an API connection with the tokens directly.
43
+
In certain advanced scenarios, you may want to obtain an access and refresh
44
+
token yourself through manual calls to the API. In this case, you can create an
45
+
API connection with the tokens directly.
32
46
33
47
```java
34
48
BoxAPIConnection api =newBoxAPIConnection("YOUR-CLIENT-ID", "YOUR-CLIENT-SECRET", "YOUR-ACCESS-TOKEN",
@@ -38,7 +52,10 @@ BoxAPIConnection api = new BoxAPIConnection("YOUR-CLIENT-ID", "YOUR-CLIENT-SECRE
38
52
Auto-Refresh
39
53
------------
40
54
41
-
By default, a `BoxAPIConnection` will automatically refresh the access token if it has expired. To disable auto-refresh, set the connection's refresh token to null. Keep in mind that you will have to manually refresh and update the access token yourself.
55
+
By default, a `BoxAPIConnection` will automatically refresh the access token if
56
+
it has expired. To disable auto-refresh, set the connection's refresh token to
57
+
null. Keep in mind that you will have to manually refresh and update the access
0 commit comments