Use Your Fingerprint with 1Password to Authenticate the Twilio CLI
Time to read: 5 minutes
In partnership with 1Password, we’d like to highlight a 1Password Shell Plugin that makes authentication with the Twilio CLI as easy as scanning your fingerprint.
You can configure 1Password to securely authenticate the Twilio CLI, so you never have to manually type your credentials in the terminal again.
Currently, developers using the Twilio CLI must first authenticate (login) before they can run commands. This often requires locating credentials in a separate window then manually entering them in the terminal.
Users are prompted to enter an Account SID and Auth Token, both of which can be found on the dashboard of the Twilio Console. Then, users are asked to enter them into the terminal like so:
This article will walk you through installing the 1Password Shell Plugin for Twilio on Mac/Linux, so you can benefit from a smoother login experience. Jump ahead to:
- A free or paid Twilio account - If you haven’t yet, sign up for a free Twilio account
- Install the latest version of the Twilio CLI - Get it here
- A 1Password account - Sign up for a 14 day trial
- Install the 1Password 8 app - For Mac or Linux
- Add your 1Password Account to the app - Add an account
- Install the 1Password CLI version 2.9.0 (or above) - Downloads available here
- Connect the 1Password CLI with the 1Password 8 app - See here
To ensure you have the correct version of the 1Password CLI, run:
To get started with the Twilio shell plugin, run:
You’ll be prompted with two options, to either import new Twilio credentials into 1Password or to search for existing Twilio credentials in 1Password.
Step 1.1: Import or select an item
Import a new item
If you haven't saved your Twilio credentials in 1Password yet, select Import into 1Password.
If 1Password detects your credentials in your local development environment, you'll be prompted to import them automatically. Otherwise, you'll need to enter your credentials manually.
You can find these credentials by creating an API Key from the Twilio Console with these steps:
- Navigate to Settings and select API Keys, or simply follow this link.
- Click the Create new API Key button, or click on the plus (+) icon if you have other API Keys already.
- Enter a friendly name for your API Key.
- Select the key type — Standard or Main.
- Click the Create API Key button.
You'll then be prompted to enter a name for the new 1Password item and select the vault where you want to save the item.
Select an existing item
If you've already saved your Twilio credentials in 1Password, select Search in 1Password.
You'll see a list of related items and the vaults where they're saved. If you don't see your credentials, select "Expand search" to browse all items in your account.
Step 1.2: Set default credential scope
After you select or import your credentials, you'll be prompted to select which vault to save your API key in; feel free to choose whichever vault you’d like.
Lastly, you’ll then be asked to configure when to use the item to authenticate the Twilio CLI.
To make the plugin available, run the following command in your terminal:
If you’re a legacy 1Password CLI user:
If you’re setting this up the first time:
For Zsh:
The next time you enter a command with the Twilio CLI, you'll be prompted to authenticate with fingerprint biometrics or system authentication (logging in with a system account password).
Inspect your configuration
To inspect your current Twilio configuration:
1Password CLI will return a list of the credentials you've configured to use with Twilio and their default scopes, as well as a list of aliases configured for Twilio.
Clear your credentials
To reset the credentials used with Twilio:
You can clear one configuration at a time, in this order of precedence:
- Terminal session default
- Directory default, from the current directory to $HOME
- Global default
For example, if you're in the directory $HOME/projects/awesomeProject
and you have a terminal session default, directory defaults for $HOME
and $HOME/projects/awesomeProject
, and a global default credential configured, you would need to run op plugin clear twilio
four times to clear all of your defaults.
To clear your global default credentials, terminal session default, and the defaults for your current directory at the same time, run op plugin clear twilio --all
.
1Password authenticates with Twilio by injecting environment variables with the credentials required by the Twilio CLI commands directly from your 1Password account.
How long is the timeout?
You’ll be asked to re-authenticate via fingerprint after 10 minutes of inactivity.
Add Twilio credentials in the 1Password 8 app
Another way to input your credentials in 1Password is through the app (rather than the CLI).
- Open the 1Password 8 application
- Create a +New Item
- Select API Credential and name it Twilio API Key
- +Add another field as Password
- The titles should match the Field names from the table below
- The values should match your Twilio credentials
If you saved your Twilio credentials in the 1Password 8 app manually rather than using op plugin
to import a new item, make sure that your field names match the table below.
1Password Field names |
Environment variables |
---|---|
Account SID |
TWILIO_ACCOUNT_SID |
API Key |
TWILIO_API_KEY |
API Secret |
TWILIO_API_SECRET |
Region (optional) |
TWILIO_REGION |
If your credentials are stored in a different field, you'll be prompted to select the field manually. Field names are case insensitive. Field name tokens can be separated by whitespaces, underscores, dashes, or nothing.
The Twilio CLI can be extended through plugins which give access to new commands. You can publish your own plugins to share with the wider Twilio community, or make them private for your own—or your clients’—business workflows.
You can also explore a list of available plugins, which include:
- Dev Phone — A developer tool for testing Twilio SMS and Voice applications, even if you don't have service.
- Serverless Toolkit — Use this to streamline your development workflow with Twilio Functions & Assets.
- Twilio Assets Plugin — Allows you to upload and manage static assets in a Twilio Assets service.
- Twilio Webhook Plugin — Allows you to emulate webhook events to validate your applications and TwiML Bins.
- twilio watch — Allows you to watch debugger alerts, voice calls, and messages as they come in, in real time.
- twilio token — Install and use this plugin to generate a token for use in a client-side SDK, e.g., a chat application.
- twilio flex — Allows you to create, build, and deploy Flex plugins.
Try other third-party CLIs with the plugin
Interested in authentication with other CLI tools? 1Password Shell Plugins support over a dozen third-party CLIs. To see a list of supported CLIs:
To choose another plugin to get started with:
For more information about the 1Password Shell Plugin, check out the official documentation.
You can find the code for the shell plugins on this GitHub repo.
Or contact 1Password via Twitter @1password or via Slack at https://1password-devs.slack.com
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.