CreateAppUser returns 400
hi all,
Do you know why CreateAppUser.java returns 400?. I already setup and install RSA public key into my Box application and here is my variable setting
private static final String CLIENT_ID = "XXXX";
private static final String CLIENT_SECRET = "XXXXX";
private static final String ENTERPRISE_ID = "MYID";
private static final String PUBLIC_KEY_ID = "XXXX";
private static final String PRIVATE_KEY_FILE = "C:\\pem\\private_key.box.pem";
private static final String PRIVATE_KEY_PASSWORD = "XXXXX";
private static final String APP_USER_NAME = "fusion";
private static final int MAX_CACHE_ENTRIES = 100;
-
thanks, stack trace is
log4j:WARN No appenders could be found for logger (org.jose4j.jwa.AlgorithmFactoryFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" com.box.sdk.BoxAPIException: The API returned an error code: 400
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:70)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:30)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:423)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:209)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:184)
at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:245)
at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:305)
at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:169)
at com.wdc.box.tools.CreateAppUser.main(CreateAppUser.java:47) -
I did the same as u did, but still the same error.
does it matter that i'm not a box admin? my account type is enterprise. I used my id in the ENTERPRISE_ID
Exception in thread "main" com.box.sdk.BoxAPIException: The API returned an error code: 400
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:70)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:30)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:423)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:209)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:184)
at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:245)
at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:305)
at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:169)
at com.wdc.box.tools.CreateAppUser.main(CreateAppUser.java:47) -
Did you grant access?
https://docs.box.com/docs/app-auth#section-3-grant-access-in-enterprise-admin-console
-
Ken, i heard a service account will be created upon authorization.
- how do i obtain that account since its a backend account that my box admin has no ideas?
- what role does this service account play in creating app user?
- once app user is created, can i add it to any shared folder for collaboration through box web?
-
1. You can see the AppUser or ServiceAccount content through admin console -> content manager
2. The ServiceAccount creates the AppUser
// 1. I think this is the ServiceAccount BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection( ENTERPRISE_ID, CLIENT_ID, CLIENT_SECRET, encryptionPref, accessTokenCache); // 2. The AppUser is created here CreateUserParams params = new CreateUserParams(); params.setSpaceAmount(removed for privacy4); //1 GB BoxUser.Info user = BoxUser.createAppUser(api, APP_USER_NAME, params);
3. I believe you can do it programmatically but not through box web since AppUsers are hidden.
-
my box admin said she has authorized my app, but i still have the same error.
when she authorizes it, is there any thing she needs to give me?
do you know how to create app user via postman?
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" com.box.sdk.BoxAPIException: The API returned an error code: 400
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:70)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:30)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:423)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:209)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:184)
at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:245)
at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:305)
at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:169)
at com.wdc.box.tools.CreateAppUser.main(CreateAppUser.java:47) -
Working with support, this is what we've got working...
BoxDeveloperEditionAPIConnection api = BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection( ENTERPRISE_ID, CLIENT_ID, CLIENT_SECRET, encryptionPref, accessTokenCache); BoxUser.Info userInfo = BoxUser.getCurrentUser(api).getInfo(); System.out.format("Welcome, %s!\n\n", userInfo.getName()); Iterable managedUsers = BoxUser.getAllEnterpriseUsers(api); for (BoxUser.Info managedUser : managedUsers) { System.out.println(managedUser.getName() + " " + managedUser.getStatus()); if (managedUser.getStatus().equals(BoxUser.Status.ACTIVE)) { // used to get AppUser or ManagedUser BoxDeveloperEditionAPIConnection userApi = BoxDeveloperEditionAPIConnection.getAppUserConnection(managedUser.getID(), CLIENT_ID, CLIENT_SECRET, encryptionPref, accessTokenCache); BoxFolder boxFolder = BoxFolder.getRootFolder(userApi); Iterable items = boxFolder.getChildren("name"); for (BoxItem.Info item : items) { System.out.println("\t" + item.getName()); } break; // 400 means they haven't accepted TOC // 403 means - inactive } }
-
I'll start adding JWT examples here:
https://github.com/kendomen/BoxJavaJWTExamples
-
thanks Ken for your very hard work. but i still getting 400.
is there any way for me to confirm that my box admin has authorized my app? I'm skeptical that she did it now
Exception in thread "main" com.box.sdk.BoxAPIException: The API returned an error code: 400
at com.box.sdk.BoxAPIResponse.(BoxAPIResponse.java:70)
at com.box.sdk.BoxJSONResponse.(BoxJSONResponse.java:30)
at com.box.sdk.BoxAPIRequest.trySend(BoxAPIRequest.java:423)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:209)
at com.box.sdk.BoxAPIRequest.send(BoxAPIRequest.java:184)
at com.box.sdk.BoxDeveloperEditionAPIConnection.authenticate(BoxDeveloperEditionAPIConnection.java:245)
at com.box.sdk.BoxDeveloperEditionAPIConnection.tryRestoreUsingAccessTokenCache(BoxDeveloperEditionAPIConnection.java:305)
at com.box.sdk.BoxDeveloperEditionAPIConnection.getAppEnterpriseConnection(BoxDeveloperEditionAPIConnection.java:169)
at com.wdc.box.tools.CreateAppUser.main(CreateAppUser.java:60)
サインインしてコメントを残してください。
コメント
16件のコメント