Difference between "App User Connection" and "App Enterprise Connection"
AnsweredI am using box-java-sdk v2.25.1 and I am trying to upload a file to box account via the OAuth2 + JWT application that i have created, for which I am trying to do this:
BoxFolder rootFolder = BoxFolder.getRootFolder(boxClient); FileInputStream stream = new FileInputStream("C:\\files\\pic.svg"); BoxFile.Info newFileInfo = rootFolder.uploadFile(stream, "image.svg");
The difference here is when I am creating the "boxClient" like this I am able to see the file that above code just uploaded under "All Files" section:
boxClient = BoxDeveloperEditionAPIConnection.getAppUserConnection(userId, boxConfig, accessTokenCache);
But when I am creating the "boxClient" like this I can not see the file that i just uploaded, although the upload went well without any error/exception:
boxClient = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(enterpriseId, clientId, clientSecret, jwtPreferences, accessTokenCache);
So what is the difference between "getAppEnterpriseConnection" and "getAppUserConnection"? Where I can actually see the file that I uploaded using "getAppEnterpriseConnection" API?
Thanks in advance!
-
Hi jeetprakash,
In short, the two different methods are generating tokens for two different users. This is why you do not see the file uploaded under the EnterpriseConnection's (your application's) account.
When you authorize a JWT application in an enterprise, it creates a new account referred to as a Service Account. This is a separate box account within your enterprise but is only accessible via the API and the Admin portal.
The getAppEnterpriseConnection method will give you a token for this service account which can access it's own content. The enterpriseId passed in the method helps to identify the correct Enterprise's service account to access for the application since an application an be authorized by more than one enterprise and therefore have more than a one Service Account associated with it. The Service Account's content is intended to me managed/viewed through the API but you can view it's content in the Web Application too in the Admin Console. You will need to have Admin or Co-Admin access within the enterprise with the ability to view users content in the web app. The Account's "Name" under the Manage Content section of the admin console matches the name of either your Application (for the Service account) or the User Name (for the Application Account). Here, you can view the account's content.
The getAppUserConnection on the other hand takes in a User Id for an Application User Account managed by your Application (see difference between Application users and Managed users here) and returns a token for that user and it's content.
I hope this helps!
Please sign in to leave a comment.
Comments
1 comment