Skip to content

Commit ba94103

Browse files
committed
Merge pull request #66 from codyebberson/cody-custom-domains
Fixed custom domain support
2 parents 5f686f2 + 937d085 commit ba94103

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/main/java/com/box/sdk/BoxAPIConnection.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public class BoxAPIConnection {
4444
private String userAgent;
4545
private String accessToken;
4646
private String refreshToken;
47+
private String tokenURL;
4748
private String baseURL;
4849
private String baseUploadURL;
4950
private boolean autoRefresh;
@@ -71,6 +72,7 @@ public BoxAPIConnection(String clientID, String clientSecret, String accessToken
7172
this.clientSecret = clientSecret;
7273
this.accessToken = accessToken;
7374
this.refreshToken = refreshToken;
75+
this.tokenURL = TOKEN_URL_STRING;
7476
this.baseURL = DEFAULT_BASE_URL;
7577
this.baseUploadURL = DEFAULT_BASE_UPLOAD_URL;
7678
this.autoRefresh = true;
@@ -108,7 +110,7 @@ public BoxAPIConnection(String clientID, String clientSecret) {
108110
public void authenticate(String authCode) {
109111
URL url = null;
110112
try {
111-
url = new URL(TOKEN_URL_STRING);
113+
url = new URL(this.tokenURL);
112114
} catch (MalformedURLException e) {
113115
assert false : "An invalid token URL indicates a bug in the SDK.";
114116
throw new RuntimeException("An invalid token URL indicates a bug in the SDK.", e);
@@ -147,6 +149,24 @@ public long getExpires() {
147149
return this.expires;
148150
}
149151

152+
/**
153+
* Gets the token URL that's used to request access tokens. The default value is
154+
* "https://www.box.com/api/oauth2/token".
155+
* @return the token URL.
156+
*/
157+
public String getTokenURL() {
158+
return this.tokenURL;
159+
}
160+
161+
/**
162+
* Sets the token URL that's used to request access tokens. For example, the default token URL is
163+
* "https://www.box.com/api/oauth2/token".
164+
* @param tokenURL the token URL.
165+
*/
166+
public void setTokenURL(String tokenURL) {
167+
this.tokenURL = tokenURL;
168+
}
169+
150170
/**
151171
* Gets the base URL that's used when sending requests to the Box API. The default value is
152172
* "https://api.box.com/2.0/".
@@ -317,7 +337,7 @@ public void refresh() {
317337

318338
URL url = null;
319339
try {
320-
url = new URL(TOKEN_URL_STRING);
340+
url = new URL(this.tokenURL);
321341
} catch (MalformedURLException e) {
322342
this.refreshLock.writeLock().unlock();
323343
assert false : "An invalid refresh URL indicates a bug in the SDK.";

src/main/java/com/box/sdk/BoxFolder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class BoxFolder extends BoxItem implements Iterable<BoxItem.Info> {
3030
"item_status", "item_collection", "sync_state", "has_collaborations", "permissions", "tags",
3131
"can_non_owners_invite"};
3232

33-
private static final String UPLOAD_FILE_URL_BASE = "https://upload.box.com/api/2.0/";
3433
private static final URLTemplate CREATE_FOLDER_URL = new URLTemplate("folders");
3534
private static final URLTemplate COPY_FOLDER_URL = new URLTemplate("folders/%s/copy");
3635
private static final URLTemplate DELETE_FOLDER_URL = new URLTemplate("folders/%s?recursive=%b");
@@ -322,7 +321,7 @@ public BoxFile.Info uploadFile(InputStream fileContent, String name, long fileSi
322321
* @return the uploaded file's info.
323322
*/
324323
public BoxFile.Info uploadFile(FileUploadParams uploadParams) {
325-
URL uploadURL = UPLOAD_FILE_URL.build(UPLOAD_FILE_URL_BASE);
324+
URL uploadURL = UPLOAD_FILE_URL.build(this.getAPI().getBaseUploadURL());
326325
BoxMultipartRequest request = new BoxMultipartRequest(getAPI(), uploadURL);
327326
request.putField("parent_id", getID());
328327

0 commit comments

Comments
 (0)