Unable to access Box File System with Developer Token using Box JDK
I have obtained a 60 minute developer token but cannot then use it in the advertised code snippet. In the below, everything is fine until I run the for(...) line in my debugger when I get the error message:
Exception in thread "main" com.box.sdk.BoxAPIResponseException: The API returned an error code [401 | 42vo6ygjyyshi0ay.05ffad8337146eb879749677ff77429db] unauthorized - Unauthorized - Cannot authorize with this service
I am using box-java-sdk-2.50.1.jar along with minimal-json-0.9.1.jar. Employees of my company use our enterprise Single Sign On (SSO) to access Box.
*****
public static void main(String[] args) {
BoxAPIConnection api = new BoxAPIConnection("pasted-in-token");
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
for (BoxItem.Info itemInfo : rootFolder) {
System.out.format("[%s] %s\n", itemInfo.getID(), itemInfo.getName());
}
}
-
Official comment
Hello Jonathan,
Can you confirm the authentication method you're using and that your application has been correctly authorized in the Box admin console?
Best,
Kourtney
Comment actions -
Hi Kourtney,
I am using Standard OAuth 2.0 (User Authentication). Here is a screen shot from the Box admin console:
Although this method says that it "Requires Box users to log in with a username and password to authorize your app to access content in their account" this never seems to happen, though I am logged into Box in an independent browser window. I would actually prefer not to use this method but I could not find a code snippet that showed how to use with OAuth 2.0 Credentials.
Jon
Please sign in to leave a comment.
Comments
2 comments