Hi Support.
ClientId: 2xbr8cf7p0xyu7n4xzc5qu0nv2sr6xor
ClientSecret: REDACTED
UserId: 17109425276
Enterprise Id: 843092337
I generated access_token without SDK. but the access_token is not working to load root folder.
I just used sample code from GitHub to get access_token.
but the access_token is not working to load root folder.
letkey = {
key:config.boxAppSettings.appAuth.privateKey,
passphrase:config.boxAppSettings.appAuth.passphrase
}
console.log('config', config)
// We will need the authenticationUrl again later,
// so it is handy to define here
constauthenticationUrl = 'https://api.box.com/oauth2/token'
try {
letclaims = {
'iss':config.boxAppSettings.clientID,
'sub':config.enterpriseID,
'box_sub_type':'enterprise',
'aud':authenticationUrl,
// This is an identifier that helps protect against
// replay attacks
'jti':crypto.randomBytes(64).toString('hex'),
// We give the assertion a lifetime of 60 seconds
// before it expires
'exp':Math.floor(Date.now() / 1000) + 60
}
letkeyId = config.boxAppSettings.appAuth.publicKeyID
// Rather than constructing the JWT assertion manually, we are
// using the jsonwebtoken library.
letassertion = jwt.sign(claims, key, {
// The API support "RS256", "RS384", and "RS512" encryption
'algorithm':'RS256',
'keyid':keyId,
})
console.log('assertion: ', assertion)
// We are using the excellent axios package
// to simplify the API call
letaccessToken = awaitaxios.post(
authenticationUrl,
querystring.stringify({
// This specifies that we are using a JWT assertion
// to authenticate
grant_type:'urn:ietf:params:oauth:grant-type:jwt-bearer',
// Our JWT assertion
assertion:assertion,
// The OAuth 2 client ID and secret
client_id:config.boxAppSettings.clientID,
client_secret:config.boxAppSettings.clientSecret
})
)
// Extract the access token from the API response
.then(response => response.data.access_token)
https://api.box.com/2.0/folders/0/items?fields=modified_at,name,extension&usemarker=true
Thank you
Justin