Box content picker on Visualforce page using dynamic access tokens
I am able to use the Content picket UI in a visualforce page in salesforce using the access token hardcoded...
However when i try calling a method to generate the access token, pass that into a variable and then use that on the Content Picket UI, it results in a 'Fetch folder error'. Any inputs would be highly appreciated..
Below is the code used:
VF Page:
Box File Selection
>
rel="stylesheet"
href="https://cdn01.boxcdn.net/platform/elements/11.0.2/en-US/picker.css"
/>
>
Apex Controller
*********************
global class TestPage {
static string token{get;set;}
public TestPage(ApexPages.StandardController controller) {
}
public void getToken(){
//box sdk
String enterpriseId = '274393287';
String publicKeyId = 'gfiim04i';
String privateKey = '';
String clientId = '2wnfzozkvwrga42jixsnaw4iwm16xxxx';
String clientSecret = 'VliZEIqpCFqiSgBQN13OwOXrZxxxxxxx';
BoxJwtEncryptionPreferences preferences = new BoxJwtEncryptionPreferences();
preferences.setPublicKeyId(publicKeyId);
preferences.setPrivateKey(privateKey);
BoxPlatformApiConnection api = BoxPlatformApiConnection.getAppEnterpriseConnection(enterpriseId, clientId, clientSecret, preferences);
system.debug('access token ==> '+ api.accesstoken);
token = string.valueOf(api.accesstoken);
}
}
-
The issue seems to be that the Service account for the JWT application needs to be added as a collaborator to the parent folder in order to have access to the folders. Once the access was granted, the access token generated dynamically was working fine to deliver the Content UI elements.
Please sign in to leave a comment.
Comments
3 comments