Closed AI-General closed 2 months ago
I am closing this issue. It could have been related to a bug in the SDK that prevented it from properly loading the key from a file, which has been resolved. It is also possible that the variable for the private key was not loading from the correct spot. If you are still having an issue, please report it to the Node SDK repo instead
When I am running code https://github.com/Vonage/vonage-node-code-snippets/blob/master/voice/make-call.js, I found following error
Error: secretOrPrivateKey must be an asymmetric key when using RS256 at module.exports (/root/vonage-node-code-snippets/node_modules/jsonwebtoken/sign.js:130:22) at tokenGenerate (/root/vonage-node-code-snippets/node_modules/@vonage/jwt/dist/tokenGenerate.js:97:12) at Auth.createBearerHeader (/root/vonage-node-code-snippets/node_modules/@vonage/auth/dist/auth.js:140:54) at Voice.addAuthenticationToRequest (/root/vonage-node-code-snippets/node_modules/@vonage/server-client/dist/client.js:82:52) at Voice.prepareRequest (/root/vonage-node-code-snippets/node_modules/@vonage/server-client/dist/client.js:256:30) at Voice.sendRequest (/root/vonage-node-code-snippets/node_modules/@vonage/server-client/dist/client.js:212:34) at Voice.sendRequestWithData (/root/vonage-node-code-snippets/node_modules/@vonage/server-client/dist/client.js:196:27) at Voice.sendPostRequest (/root/vonage-node-code-snippets/node_modules/@vonage/server-client/dist/client.js:169:21) at Voice.createOutboundCall (/root/vonage-node-code-snippets/node_modules/@vonage/voice/dist/voice.js:202:33) at Object. (/root/vonage-node-code-snippets/voice/make-call.js:24:14)
This error occured on following code snippet:
const vonage = new Vonage({ apiKey: VONAGE_API_KEY, apiSecret: VONAGE_API_SECRET, applicationId: VONAGE_APPLICATION_ID, privateKey: privateKey, })
const vonage = new Vonage({ apiKey: VONAGE_API_KEY, apiSecret: VONAGE_API_SECRET, applicationId: VONAGE_APPLICATION_ID, privateKey: VONAGE_APPLICATION_PRIVATE_KEY_PATH })
Possible Solution
const privateKey = fs.readFileSync(VONAGE_APPLICATION_PRIVATE_KEY_PATH);
const vonage = new Vonage({ apiKey: VONAGE_API_KEY, apiSecret: VONAGE_API_SECRET, applicationId: VONAGE_APPLICATION_ID, privateKey: privateKey, })
My question
Is it same in feature?