Box API returns HTTP 403 when trying to collaborate APP-USER
I am having a problem trying to give collaboration rights to an App-User.
First, I create an enterprise API connection. Works fine.
Second, I create App User,
Third, I try to give App User access rights to the root folder of the owner:
BoxFolder root = BoxFolder.getRootFolder(enterpriseAccess); root.collaborate(userInfo.getLogin(), BoxCollaboration.Role.VIEWER_UPLOADER);
The collaborate method takes BoxAPIException with message: "The API returned an error code: 403"
Here is my Java code to create a Box App-user connection:
BoxAPIConnection enterpriseAccess = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(boxConfig.getEnterpriseId(), boxConfig.getClientId(), boxConfig.getClientSecret(), encryptionPreferences, accessTokenCache); if (proxy != null) { enterpriseAccess.setProxy(proxy); } CreateUserParams cup = new CreateUserParams(); cup.setIsPlatformAccessOnly(true); BoxUser.Info userInfo = BoxUser.createAppUser(enterpriseAccess, APP_USER_NAME, cup); // // Now we need to give App User collaboration rights: // BoxFolder root = BoxFolder.getRootFolder(enterpriseAccess); root.collaborate(userInfo.getLogin(), BoxCollaboration.Role.VIEWER_UPLOADER); // this.boxAppUserConx = BoxDeveloperEditionAPIConnection.getAppUserConnection(userInfo.getLogin(), boxConfig.getClientId(), boxConfig.getClientSecret(), encryptionPreferences, accessTokenCache); // this.boxAppUserConx.setRequestInterceptor(new RequestInterceptor() { /** * @see com.box.sdk.RequestInterceptor#onRequest(com.box.sdk.BoxAPIRequest) */ public BoxAPIResponse onRequest(BoxAPIRequest request) { request.addHeader("As-User", boxConfig.getAppUserName()); // Returning null means the request will be sent along with our new header. return null; } });
-
I also tried using the user-id rather than the email address:
BoxFolder root = BoxFolder.getRootFolder(enterpriseAccess); BoxCollaborator collaborator = new BoxUser(enterpriseAccess, APP_USER_NAME); root.collaborate(collaborator, BoxCollaboration.Role.VIEWER_UPLOADER);
This returned a 404:
{"type":"error","status":404,"code":"not_found","context_info":{"errors":[{"reason":"invalid_parameter","name":"id","message":"Invalid value 'qed.warehouse'. 'id' with value 'qed.warehouse' not found"}]},"help_url":"http:\\/\\/developers.box.com\\/docs\\/#errors","message":"Not Found","request_id":"removed for privacy57a8c5526b735"}
It is as if my new App User was not created.
サインインしてコメントを残してください。
コメント
1件のコメント