Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access Token error due to library changes in newer versions of twilio-node #561

Open
danohn opened this issue May 22, 2024 · 0 comments · May be fixed by #562
Open

Access Token error due to library changes in newer versions of twilio-node #561

danohn opened this issue May 22, 2024 · 0 comments · May be fixed by #562

Comments

@danohn
Copy link

danohn commented May 22, 2024

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

  1. Clone the repo
  2. Copy the .env.example file and update the .env file as needed
  3. Run the twilio serverless:deploy command
  4. 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;
danohn added a commit to danohn/voice-quickstart-ios that referenced this issue May 22, 2024
This commit fixes twilio#561
@danohn danohn linked a pull request May 22, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant