Giter Club home page Giter Club logo

plugin-token's Introduction

@twilio/plugin-token

Generate a temporary token for use in a Twilio client-side SDK application

Requirements

Setup

Head over to the twilio-cli documentation.

Usage

$ twilio plugins:install @twilio-labs/plugin-token
$ twilio --help token
USAGE
  $ twilio token
...

Commands

twilio token:capability:client

USAGE
  $ twilio token:capability:client

OPTIONS
  -l=(debug|info|warn|error|none)            [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)                 [default: columns] Format of command output.
  -p, --profile=profile                      Shorthand identifier for your profile.
  --allow-incoming=true|false                [default: true] Allow incoming calls (true/false) (defaults to true)
  --identity=identity                        (required) The user identity

  --push-credential-sid=push-credential-sid  The Push Credential SID for receiving incoming call push notifications,
                                             starts with CRXXX

  --silent                                   Suppress output and logs. This is a shorthand for "-l none -o none".

  --ttl=ttl                                  Optional TTL for token (up to 24 hours) (value in seconds)

  --voice-app-sid=voice-app-sid              (required) The TwiML Application SID for outbound calls, starts with APXXX

See code: src/commands/token/capability/client.js

twilio token:capability:worker

USAGE
  $ twilio token:capability:worker

OPTIONS
  -l=(debug|info|warn|error|none)  [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)       [default: columns] Format of command output.
  -p, --profile=profile            Shorthand identifier for your profile.
  --silent                         Suppress output and logs. This is a shorthand for "-l none -o none".
  --ttl=ttl                        Optional TTL for token (up to 24 hours) (value in seconds)
  --worker-sid=worker-sid          (required) The Worker SID for this token
  --workspace-sid=workspace-sid    (required) The Workspace SID for this token

See code: src/commands/token/capability/worker.js

twilio token:chat

USAGE
  $ twilio token:chat

OPTIONS
  -l=(debug|info|warn|error|none)      [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)           [default: columns] Format of command output.
  -p, --profile=profile                Shorthand identifier for your profile.
  --chat-service-sid=chat-service-sid  (required) The service SID for the Chat, starts with ISXXX
  --identity=identity                  (required) The user identity
  --silent                             Suppress output and logs. This is a shorthand for "-l none -o none".
  --ttl=ttl                            Optional TTL for token (up to 24 hours) (value in seconds)

See code: src/commands/token/chat.js

twilio token:flex

USAGE
  $ twilio token:flex

OPTIONS
  -l=(debug|info|warn|error|none)  [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)       [default: columns] Format of command output.
  -p, --profile=profile            Shorthand identifier for your profile.
  --silent                         Suppress output and logs. This is a shorthand for "-l none -o none".
  --ttl=ttl                        Optional TTL for token (up to 24 hours) (value in seconds)
  --worker-sid=worker-sid          (required) The Worker SID for this token
  --workspace-sid=workspace-sid    (required) The Workspace SID for this token

See code: src/commands/token/flex.js

twilio token:sync

USAGE
  $ twilio token:sync

OPTIONS
  -l=(debug|info|warn|error|none)      [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)           [default: columns] Format of command output.
  -p, --profile=profile                Shorthand identifier for your profile.
  --identity=identity                  (required) The user identity
  --silent                             Suppress output and logs. This is a shorthand for "-l none -o none".
  --sync-service-sid=sync-service-sid  (required) The service SID for the Sync, starts with ISXXX
  --ttl=ttl                            Optional TTL for token (up to 24 hours) (value in seconds)

See code: src/commands/token/sync.js

twilio token:video

USAGE
  $ twilio token:video

OPTIONS
  -l=(debug|info|warn|error|none)  [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)       [default: columns] Format of command output.
  -p, --profile=profile            Shorthand identifier for your profile.
  --identity=identity              (required) The user identity
  --room-name=room-name            The name of the room this token grants access to
  --silent                         Suppress output and logs. This is a shorthand for "-l none -o none".
  --ttl=ttl                        Optional TTL for token (up to 24 hours) (value in seconds)

See code: src/commands/token/video.js

twilio token:voice

USAGE
  $ twilio token:voice

OPTIONS
  -l=(debug|info|warn|error|none)            [default: info] Level of logging messages.
  -o=(columns|json|tsv|none)                 [default: columns] Format of command output.
  -p, --profile=profile                      Shorthand identifier for your profile.
  --allow-incoming=true|false                [default: true] Allow incoming calls (true/false) (defaults to true)
  --identity=identity                        (required) The user identity

  --push-credential-sid=push-credential-sid  The Push Credential SID for receiving incoming call push notifications,
                                             starts with CRXXX

  --silent                                   Suppress output and logs. This is a shorthand for "-l none -o none".

  --ttl=ttl                                  Optional TTL for token (up to 24 hours) (value in seconds)

  --voice-app-sid=voice-app-sid              (required) The TwiML Application SID for outbound calls, starts with APXXX

See code: src/commands/token/voice.js

Contributing

This project welcomes contributions from the community. Please see the CONTRIBUTING.md file for more details.

Code of Conduct

Please be aware that this project has a Code of Conduct. The tldr; is to just be excellent to each other ❤️

License

MIT

plugin-token's People

Contributors

bobiechen-twilio avatar crweiner avatar dependabot[bot] avatar dkundel avatar dprothero avatar jefflinwood avatar micaswyers avatar mmena1 avatar philnash avatar snyk-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

plugin-token's Issues

oclif readme command doesn't work

When trying to auto-generate the README using oclif-dev, I ran into an issue:
..

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1070:16)
    at Module._compile (internal/modules/cjs/loader.js:1120:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Module.require (internal/modules/cjs/loader.js:1042:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/Users/mswyers/work/plugin-token/node_modules/@oclif/core/lib/index.js:6:19)
    at Module._compile (internal/modules/cjs/loader.js:1156:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
module: @oclif/[email protected]
task: toCached
plugin: @twilio-labs/plugin-token
root: /Users/<me>/work/plugin-token
See more details with DEBUG=*
(node:83873) SyntaxError Plugin: @twilio-labs/plugin-token: Unexpected token '.'
module: @oclif/[email protected]
task: toCached
plugin: @twilio-labs/plugin-token
root: /Users/<me>/work/plugin-token
See more details with DEBUG=*
/Users/<me>/work/plugin-token/node_modules/@twilio/cli-core/node_modules/@oclif/core/lib/command.js:51
            delete this.globalFlags?.json;
                                    ^
                                    ^

Because it is no longer supported, I have removed the oclif-dev dependency from package.json. In SCRIPTS, you should be able to generate the readme with:

oclif readme

(and oclif manifest in the prepack step)

However, it looks like there's a bug in the @oclif/core module.

[DEBUG] identity is required to be specified in options

[DEBUG] Error: identity is required to be specified in options
at new AccessToken (/Users/mavis/.twilio-cli/node_modules/twilio/lib/jwt/AccessToken.js:28:19)
at VoiceTokenGenerator.createToken (/Users/mavis/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/helpers/accessToken.js:14:23)
at VoiceTokenGenerator.run (/Users/mavis/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/commands/token/voice.js:17:37)
at async VoiceTokenGenerator._run (/Users/mavis/.twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)
at async Config.runCommand (/usr/local/lib/node_modules/twilio-cli/node_modules/@oclif/core/lib/config/config.js:301:25)

When a user has an Account Sid and Auth Token in the environment token is incorrect

If a user has an Account Sid and Auth Token in the environment as TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN then the Twilio CLI prefers that over any saved profiles.

When generating a token, we need the API Key and Secret. But in the above scenario the API Key is set to be the Account Sid and the API Secret is set to be the Auth Token so the token is created using the Account Sid twice and is thus invalid.

You can work around this by setting a profile in the command:

twilio token:chat --identity philnash --chat-service-sid ISXXX --profile hello

Or by setting an API Key and API Secret in the environment too:

TWILIO_API_KEY=SKXXX TWILIO_API_SECRET=ABC123 twilio token:chat --identity philnash --chat-service-sid ISXXX 

This plugin should try to detect whether the API Key looks like an API Key (starts with "SK") and return a warning if it is an Account Sid instead (starts with "AC"). It can recommend the above mitigations as part of the warning.

Twilio labs token plugin does not install.

When I run twilio plugins:install @twilio-labs/plugin-token the terminal says it's installing, however, I have waited hours and no progress. I get a couple of warnings after I run the installation as seen below:
warning ../package.json: No license field warning Waiting for the other yarn instance to finish (pid undefined, inside undefined)

Any ideas on how to fix this issue? Thank you for your help.

twilio token:voice --identity=alice --voice-app-sid=AP40f04d5c678c9fd3a3b5add1724395e8 -l debug

Error is

[DEBUG] Config File: /Users/ganga.k/.twilio-cli/config.json
[DEBUG] Using profile: Twilio_Staging_Mobile
[DEBUG] Found command "token:voice" plugin: @twilio-labs/plugin-token
» twilio-cli encountered an unexpected error. To report this issue, execute the command with the "-l debug" flag, then copy the output to a new issue here: "https://github.com/twilio-labs/plugin-token/issues"
[DEBUG] identity is required to be specified in options
[DEBUG] Error: identity is required to be specified in options
at new AccessToken (/Users/ganga.k/.twilio-cli/node_modules/twilio/lib/jwt/AccessToken.js:28:19)
at VoiceTokenGenerator.createToken (/Users/ganga.k/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/helpers/accessToken.js:14:23)
at VoiceTokenGenerator.run (/Users/ganga.k/.twilio-cli/node_modules/@twilio-labs/plugin-token/src/commands/token/voice.js:17:37)
at async VoiceTokenGenerator._run (/Users/ganga.k/.twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)
at async Config.runCommand (/Users/ganga.k/.npm-global/lib/node_modules/twilio-cli/node_modules/@oclif/core/lib/config/config.js:301:25)
› Error: EEXIT: 1
› Code: EEXIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.