Box API -- Uploaded file not seen
Hi, We have a need to create a shared folder/directory in Box that will store files uploaded via an integration. As this will be an automated process and server-server integration, I went ahead and created a custom app, using the developer console. I used the "OAuth2.0 with JWT" authentication and followed the quickstart guide for creating a custom application. In the configuration properties, I set the "Application Access" to "enterprise, and turned on toggles for both "Perform Actions as Users" and "Generate User Access Tokens" options.Also I had my enterprise admin to "authorize" my custom app. Generated the public/private key, downloaded the json file and build a simple java poc to upload files. I am able to upload files, but I dont see the file using my box account. I added another box user as a collaborator to this custom app, but neither he can access/see the uploaded file in his box account.
My question is how can see the files uploaded to the custom app or the service account. Do I need to do anything else or need any additional authorization from the "enterprise box admin". I dont seem to have access to any admin-console. How can I or other box users in my company access these files that I uploaded to the custom app.
Appreciate any pointers or help. Thanks
-Kal
-
Hi there!Great question! A service account is an API-only account. What this means is that files and folders can't be accessed through the box Webapp. There are two ways you can access this content:
- Via the API. You can make an API call with an application level token to manage content and access the content within the service account. For example, our get files endpoint!
- In the Content Manager Tab located within the Admin console. Within your admin console, select the content manager tab, and select the application name that you would like to view content for!
We have a great page that provides more information on this: https://developer.box.com/docs/service-account -
Thank you for your response. Reviewing the reference you gave, I see that since it is api-only account, it wont come up in the web-app. As follow-up to my requirement or as a workaround, I was wondering if we create a folder under the service-account and add collaborators (they will be the enterprise users or the managed users) to that folder, then will it show up under my or other managed users accounts.
So, to test that, I used the java sdk for the box apis and created a folder under the root-folder using the apis. Then I tried to add a collaborators (an enterprise user or a managed user) to the folder, using the java api's, "BoxFolder.collaborate" , but it is throwing an error. Any idea what could be the reason. Below is the exception.
--------------
Exception in thread "main" com.box.sdk.BoxAPIException: The API returned an error code: 400
{"type":"error","status":400,"code":"bad_request","context_info":{"errors":[{"reason":"missing_parameter","name":"login","message":"'login' is required"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Bad Request","request_id":"ik0oejfz7d3522bb"}
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:85)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:32)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:479)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:265)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:240)
at com.box.sdk.BoxFolder.collaborate(BoxFolder.java:164)
at com.box.sdk.BoxFolder.collaborate(BoxFolder.java:131)
at com.example.boxintegration.MyBoxUtil.addCollaboratorToFolder(MyBoxUtil.java:154)
at com.example.boxintegration.test.TestBoxClientUtil.main(TestBoxClientUtil.java:15)---------------------------
I didnt get why it is saying "login is required", even though it is a api-only account and the authentication is already handled using the JWT file.
Thanks
-
Hi can someone please comment or throw a pointer. I am kind a stuck here. I dont want to engage our "enterprise-admin" to add collaborators to folders under the service-account, which I created, since me or my team wants to manage the folders and data under that service-account. Please help.
Thanks
-
Thanks for responding Kourt.
I didnt gave a "userID", since I didnt how to get that information. But I gave "emailAddress" to the api as below.folder = new BoxFolder(client, folderID); //I provided the folderID, client and the complete emailAddress (as @.com) through a wrapper.
BoxCollaboration.Info collabInfo;
if (userID == null && userID.isEmpty()) {
collabInfo = folder.collaborate(emailAddress,BoxCollaboration.Role.EDITOR);
}
Please sign in to leave a comment.
Comments
9 comments