Box Node SDK TypeError when refreshing App Auth AccessToken on heroku.
Hi,
I am having trouble authenticating to Box with the Node Box SDK when deployed on heroku.
This is the error I am getting:
TypeError: key must be a string or buffer
at typeError (/app/node_modules/jwa/index.js:14:10)
at Object.sign (/app/node_modules/jwa/index.js:48:13)
at Object.jwsSign [as sign] (/app/node_modules/jws/lib/sign-stream.js:23:26)
at Object.JWT.sign (/app/node_modules/jsonwebtoken/index.js:137:16)
at TokenManager.getTokensJWTGrant (/app/node_modules/box-node-sdk/lib/token-manager.js:329:24)
at AppAuthSession._refreshAppAuthAccessToken (/app/node_modules/box-node-sdk/lib/sessions/app-auth-session.js:77:20)
at AppAuthSession.getAccessToken (/app/node_modules/box-node-sdk/lib/sessions/app-auth-session.js:110:8)
at BoxClient.upload (/app/node_modules/box-node-sdk/lib/box-client.js:522:7)
at BoxClient._makeRequest (/app/node_modules/box-node-sdk/lib/box-client.js:208:16)
at Files.uploadFile (/app/node_modules/box-node-sdk/lib/managers/files.js:540:14)
.....
This happens when trying to interact with the Box API using the SDK. For example with the following line of code:
client._session._refreshAppAuthAccessToken((err, accessToken) => { ...
But also with uploading:
client.files.uploadFile('0', fileToUpload.filename, stream, (err, upload) => { ...
This error only exists when the application I built is deployed to heroku and not on my development environment. The key works perfectlly fine on the development environment.
This is de code I am using to initialise the Box SDK:
const boxSDK = new BoxSDK({ clientID: 'MY_CLIENT_ID', clientSecret: 'MY_CLIENT_SECRET', appAuth: { keyID: 'MY_KEY_ID', privateKey: 'MY_PRIVATE_KEY', passphrase: 'MY_PASSPHRASE' } });
const client = boxSDK.getAppAuthClient('enterprise', 'MY_ENTERPRISE_ID');
I have tried using different versions of node (4.7.3, 6.1.0, 7.5.0). All work on the development environment but not when deployed to heroku.
I have tried logging the privateKey variable before interaction with the Box API and the variable has the correct value.
Did I miss something?
サインインしてコメントを残してください。
コメント
0件のコメント