How to correctly export all Box files for a user using JWT service account
Using a JWT service account I want to access all Box.com files for User with ID 234234 and login nick.jackson
So I create a jwt api connection:
String privateKey = new String(Files.readAllBytes(Paths.get(boxJwtPrivateKeyFile)));
JWTEncryptionPreferences encryptionPref = new JWTEncryptionPreferences();
encryptionPref.setPublicKeyID(boxJwtPublicKeyId);
encryptionPref.setPrivateKey(privateKey);
encryptionPref.setPrivateKeyPassword(boxJwtPrivateKeyPassword);
encryptionPref.setEncryptionAlgorithm(EncryptionAlgorithm.RSA_SHA_256);
IAccessTokenCache accessTokenCache = new InMemoryLRUAccessTokenCache(MAX_CACHE_ENTRIES);
api = BoxDeveloperEditionAPIConnection.getAppUserConnection(boxAppUserId, apiKey, apiSecret,
encryptionPref, accessTokenCache);
Then I set the As-User header as 234234
api.setRequestInterceptor((RequestInterceptor) request -> {
request.addHeader("As-User", "234234");
// Returning null means the request will be sent along with our new header.
return null;
});
Does this get all files owned by this user? It definitely also includes files shared to the user or available through group/user membership to a directory.
One problem - I see situations where I find files from one owner in one As-User, then when I go look for them as that user itself in As-User I don't find them. Why is that?
Example:
As-User=234234
-> has file 58583532 owned by 345525
As-User=345525
-> Don't have that file 58583532
Am I doing anything wrong?
Please sign in to leave a comment.
Comments
0 comments