Hi,
I’m a little stuck on this. We use box for our storage for clients (organisations) and with each client, we open a new folder.
The functionality I’m looking for is for an internal admin webapp. When a user logs in to the admin app, I want to retrieve a service account token so then when they create an organisation, it triggers a new folder created in the enterprise account.
All the client_ids etc are in the .env and in the dev console, the custom app is fine. Here is a copy of my server.js:
const BoxSDK = require('box-node-sdk');
// Box configuration
app.get('/api/box-access-token', cors(corsOptions), async (req, res) => {
const sdkConfig = {
boxAppSettings: {
clientID: process.env.BOX_CLIENT_ID,
clientSecret: process.env.BOX_CLIENT_SECRET,
},
enterpriseID: process.env.ENTERPRISE_ID,
}
const sdk = BoxSDK.getPreconfiguredInstance(sdkConfig)
const client = sdk.getAnonymousClient();
// Extract the necessary information
const boxSdkAccessToken = client.accessToken;
console.log('Box SDK Access Token:', boxSdkAccessToken);
// Respond with the access token
res.json({ boxSdkAccessToken }); // Updated to use 'accessToken' as the key
});
Pretty simple code block, but I’m racking my brain as in the terminal, I’m not seeing the boxSdkAccessToken.