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);
}
}