twilio-cli: Secure credential storage failed to load.

Unable to run twilio login

Hi guys,

I’m trying to get twilio running on a web server (Digital Ocean Droplet if that matters) and am having trouble getting past the first steps.

Steps to Reproduce

  1. npm install twilio-cli -g
  2. twilio login Spits out the error message:
Secure credential storage failed to load.

You can also use credentials stored in environment variables:

#  OPTION 1 (recommended)
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
TWILIO_API_KEY = an API Key created at twil.io/get-api-key
TWILIO_API_SECRET = the secret for the API Key

# OPTION 2
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
TWILIO_AUTH_TOKEN = your Auth Token from twil.io/console

I tried storing the credentials within environmental variables as suggested however the same error message comes up.

When I run twilio login -l debug, the error message gets an extra line at the bottom of: at SecureStorage.loadKeytar (/home/arj/.nvm/versions/node/v12.14.1/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/services/secure-storage.js:35:15)

I’ve not had too much experience with NVM/NPM so apologies if I’m doing something obiously incorrect.

Let me know if I’m doing anything wrong.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 10
  • Comments: 35 (15 by maintainers)

Commits related to this issue

Most upvoted comments

For anyone else running into the below error (I kept getting it after trying to run the twilio-cli after successfully logging in the first time around), I followed the above advice to add my twilio credentials to my .env file.

Error

» Installing keytar ...
 » Secure credential storage failed to load.

Fixed by adding to .env file (I’m on MacOS)

Find my shell (I’m using zsh, you could be using, bash etc.): $ echo $SHELL returns /bin/zsh Open my .zshrc file: $ open ~/.zshrc Add Twilio variables:

export TWILIO_ACCOUNT_SID=ACXXXXXXetc
export TWILIO_AUTH_TOKEN=0aXXXXXXetc

Refresh my terminal and test - $ echo $TWILIO_ACCOUNT_SID should return ACXXXXXXetc Then I was able to use twilio-cli as before.

The issue here is that the twilio login does not prompt your Account SID and Auth Token when environment variables are NOT set.

It throws that Secure credential storage failed to load. error even when one tries to login for the first time after installation.

The error message should be corrected then.

@midhunomk

export TWILIO_ACCOUNT_SID=...
export TWILIO_API_KEY=...
export TWILIO_API_SECRET=...

Note the message below is misleading, and will print out even when those variables are set:

Once these environment variables are set, a twilio-cli profile is not required to move forward with installation.

$ env | grep TWILIO

TWILIO_ACCOUNT_SID=xxx
TWILIO_API_SECRET=xxx
TWILIO_API_KEY=xxx

This seems misleading - it implies Twilio isn’t picking up the variables being set.

A better message would be to check if the environment variables are set

  • if not, present the current message
  • if so, present something like that below.

You have TWILIO_ACCOUNT_SID TWILIO_API_SECRET and TWILIO_API_KEY set, so you don’t need to run twilio login

PR to update the wording on the env var message to include the export/set command: https://github.com/twilio/twilio-cli-core/pull/93

@drewstaylor Think you need to export the vars in order for them to be available to the Node process.

@drewstaylor Got it. My concern about knowing the specific command was to ensure it wasn’t coming from some other plugin.

What version of twilio-cli and Node is this? twilio version

That doesn’t really seem to work. Today’s saga:

source .env
mbermudez@C02ZV389MD6P functions % twilio serverless:deploy --env=/Users/mbermudez/plugin-chat-sms-transfer/functions -l=debug
 » Could not find profile "undefined".
 » To create the profile, run:

  twilio profiles:create

Alternatively, twilio-cli can use credentials stored in environment variables:

# OPTION 1 (recommended)
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
TWILIO_API_KEY = an API Key created at twil.io/get-api-key
TWILIO_API_SECRET = the secret for the API Key

# OPTION 2
TWILIO_ACCOUNT_SID = your Account SID from twil.io/console
TWILIO_AUTH_TOKEN = your Auth Token from twil.io/console

Once these environment variables are set, a twilio-cli profile is not required to move forward with installation.
mbermudez@C02ZV389MD6P functions % echo $TWILIO_ACCOUNT_SID
AC93424bcb5f142c106f719c7e9bbf9231

I’ve tried different tactics here:

  • Removed my profiles one by one (didn’t work as it was expecting a shorthand identifier which isn’t very easy to find using the CLI)
  • Removed the JSON credentials configuration file
  • Updated the .env file to use TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN
  • Passed --env as a flag
  • Passed --auth-token as a flag