-
Notifications
You must be signed in to change notification settings - Fork 96
Closed
Description
Description
When running the Quickstart and requesting an Access Token from e.g. https://quickstart-1234-dev.twil.io/access-token, an error is returned with the following message:
{
"message": "identity is required to be specified in options",
"name": "Error",
"stack": "Error: identity is required to be specified in options\n at new AccessToken (/var/task/node_modules/twilio/lib/jwt/AccessToken.js:28:19)\n at exports.handler (/var/task/handlers/ZNf10e7cbc86844358c2a38dee2f1bd9a4.js:18:17)\n at exports.handler (/var/task/node_modules/runtime-handler/index.js:339:10)\n at exports.handler (/var/task/runtime-handler.js:17:17)\n at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"
}
Steps to Reproduce
- Clone the repo
- Copy the .env.example file and update the .env file as needed
- Run the
twilio serverless:deploycommand - Attempt to retrieve an Access Token from e.g. https://quickstart-1234-dev.twil.io/access-token
Expected Behavior
The function should mint an Access Token
Actual Behavior
The function returns the error:
{
"message": "identity is required to be specified in options",
"name": "Error",
"stack": "Error: identity is required to be specified in options\n at new AccessToken (/var/task/node_modules/twilio/lib/jwt/AccessToken.js:28:19)\n at exports.handler (/var/task/handlers/ZNf10e7cbc86844358c2a38dee2f1bd9a4.js:18:17)\n at exports.handler (/var/task/node_modules/runtime-handler/index.js:339:10)\n at exports.handler (/var/task/runtime-handler.js:17:17)\n at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)"
}
Reproduces How Often
100%
Fix
As per This Stack Overflow answer, with version 4 and above of the Node.js client (the current default for serverless functions is 5.0.3), you now need to supply an identity property in the AccessToken config. For example:
const token = new AccessToken(
twilioAccountSid,
twilioApiKey,
twilioApiSecret,
{ identity }
);
token.addGrant(voiceGrant);
// token.identity = identity;
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels