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

Secure credential storage failed to load. #148

Closed
akandola96 opened this issue Jan 12, 2020 · 35 comments
Closed

Secure credential storage failed to load. #148

akandola96 opened this issue Jan 12, 2020 · 35 comments
Labels
status: waiting for feedback waiting for feedback from the submitter type: security known security issue

Comments

@akandola96
Copy link

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.

@childish-sambino
Copy link
Contributor

If you're using env vars to store credentials then you don't need to run twilio login (the login command is for creating a local CLI profile that manages your credentials). After setting the env vars, you can start using other commands to interact with the Twilio API.

@childish-sambino childish-sambino added status: waiting for feedback waiting for feedback from the submitter type: security known security issue labels Jan 13, 2020
@jabowery
Copy link

The error message should be corrected then.

@childish-sambino
Copy link
Contributor

@jabowery Updated here: twilio/twilio-cli-core#80

@brodiealexander
Copy link

brodiealexander commented Apr 12, 2020

This issue still exists.
[censorsed]@[censored]:~#` twilio login
» Failed to locate the Twilio API Plugin
» Installing keytar ...
» Secure credential storage failed to load.

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.

Notes:
-OP and I share the fact that we're both on DigitalOcean Ubuntu (18.04.3 LTS)

@childish-sambino
Copy link
Contributor

@thebordie A secure credential store is not available in all environments so it fails to load. The instructions provided allow for using env vars instead of a secure credential store.

@midhunomk
Copy link

how to add in DigitalOcean Ubuntu (18.04.3 LTS), please add the command allow for using env var

@childish-sambino
Copy link
Contributor

@midhunomk

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

@vprokofev
Copy link

vprokofev commented Apr 28, 2020

I'm getting hit with the same issue here.
Here're steps to reproduce.
Clean Ubuntu 18.04.4 install inside a KVM VM, with apt update && apt upgrade && apt auroremove && reboot performed.

dev2:~$ uname -a
Linux dev2 4.15.0-96-generic #97-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
dev2:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.4 LTS
Release:        18.04
Codename:       bionic

Nodejs installed as such[1]:

curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install nodejs

followed by:

$ sudo npm install
$ npm install twilio-cli
## sudo npm install twilio-cli -g will not work due to process working under "nobody" user and having permission issues
$ sudo apt install pkg-config libsecret-1-dev
$ twilio plugins:install @twilio-labs/plugin-rtc

and now it fails:

dev2:~$ twilio login -l debug
[DEBUG] Config File: /home/user/.twilio-cli/config.json
[DEBUG] Error loading keytar: Error: Cannot find module 'keytar'
Require stack:
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/services/require-install.js
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/base-commands/base-command.js
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/index.js
- /usr/lib/node_modules/twilio-cli/bin/run
[DEBUG] Found command "login" plugin: twilio-cli
[DEBUG] Found keytar version in "@twilio/cli-core" dependencies: ^5.4.0
[DEBUG] Error loading keytar: Error: Failed to execute child process “dbus-launch” (No such file or directory)
 » Secure credential storage failed to load.
## followed by standard "Alternatively, twilio-cli" message

if I install dbus-launch with sudo apt install dbus-x11

dev2:~$ twilio login -l debug
[DEBUG] Config File: /home/user/.twilio-cli/config.json
[DEBUG] Error loading keytar: Error: Cannot find module 'keytar'
Require stack:
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/services/require-install.js
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/base-commands/base-command.js
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/index.js
- /usr/lib/node_modules/twilio-cli/bin/run
[DEBUG] Found command "login" plugin: twilio-cli
[DEBUG] Found keytar version in "@twilio/cli-core" dependencies: ^5.4.0
[DEBUG] Error loading keytar: Error: Error spawning command line “dbus-launch --autolaunch=ef568b4d97934cb487a52e832b894b22 --binary-syntax --close-stderr”: Child process exited with code 1
 » Secure credential storage failed to load.
## followed by standard "Alternatively, twilio-cli" message

and if I run a local X server on my windows machine(X-ming)

dev2:~$ twilio login -l debug
[DEBUG] Config File: /home/user/.twilio-cli/config.json
[DEBUG] Error loading keytar: Error: Cannot find module 'keytar'
Require stack:
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/services/require-install.js
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/base-commands/base-command.js
- /usr/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/index.js
- /usr/lib/node_modules/twilio-cli/bin/run
[DEBUG] Found command "login" plugin: twilio-cli
[DEBUG] Found keytar version in "@twilio/cli-core" dependencies: ^5.4.0
** Message: 12:10:49.437: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
[DEBUG] Error loading keytar: Error: The name org.freedesktop.secrets was not provided by any .service files
 » Secure credential storage failed to load.
## followed by standard "Alternatively, twilio-cli" message

And this is where I'm stuck and have no idea what's wrong.
Setting env variables does not change anything.

[1] https://github.com/nodesource/distributions/blob/master/README.md

@childish-sambino
Copy link
Contributor

@vprokofev If you use env vars for auth, then you don't need a twilio-cli profile and don't need to run the login command.

@krumbs
Copy link

krumbs commented May 4, 2020

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.

@childish-sambino
Copy link
Contributor

@krumbs Correct, before the login command prompts for any information, it attempts to load a secure credential store to make sure one's available before continuing. If this fails, an error is printed alerting you of the failure and alternative instructions on how to store credentials.

Once you've configured the env vars, then there's no need to run the login command. You can just start using the CLI and executing API commands.

@chrisnovak
Copy link

So does this mean twilio login just doesn't work? It seems much easier to the profiles API to switch between environments.

@childish-sambino
Copy link
Contributor

@chrisnovak That is correct. Without a secure credential store to put the API key secret, twilio-cli does not allow for profiles to be created.

@bermudezmt
Copy link

Hi, I'm running twilio-cli/2.1.0 darwin-x64 node-v14.3.0 in my environment and this looks to be an issue even if you don't use twilio login. I've configured the environment variables, and have even passed the --env flag to twilio serverless:list. This is the consistent output I'm seeing:

twilio serverless:list --env=~/.twilio.env
 » Installing keytar ...
 » Secure credential storage failed to load.

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.

@childish-sambino
Copy link
Contributor

@bermudezmt The env vars need to be exported to work with twilio-cli. Recommend making sure they are set. E.g., echo $TWILIO_ACCOUNT_SID

@bermudezmt
Copy link

bermudezmt commented Jun 2, 2020

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

@childish-sambino
Copy link
Contributor

@bermudezmt Reviewed the code and I'm not seeing where the hiccup is happening. The only thing I can think of is TWILIO_AUTH_TOKEN not being exported properly. I see you verified the account SID is, but do you mind also checking the auth token? Don't post it here; just confirm if it's the expected value: echo $TWILIO_AUTH_TOKEN.

@HenryPSF
Copy link

HenryPSF commented Jun 7, 2020

Hi, I tried to deploy the example https://github.com/twilio/twilio-video-app-react, y setup the set TWILIO_ACCOUNT_SID, TWILIO_API_KEY follow the twilio documentation, then I tried npm run deploy:twilio-cli, but have these error Could not find profile "undefined", but another line say Alternatively, twilio-cli can use credentials stored in environment variables.
Ok, I tried to login and a new profile and apikey was create. Then, I tried to deploy again, but now say: twilio deploy Secure credential storage failed to load but another line say Once these environment variables are set, a twilio-cli profile is not required to move forward with installation.. It es really hard to understand, for one hand the say if I set the variables, I do not nee to create a profile, but is not true. And for another hand said that is no possible get the variables. I am working on Windows 10, last versions of Node.js, last version of twilio cli and Vcode. Thanks.

@rshugs
Copy link

rshugs commented Jun 14, 2020

Couldn't use login. ENV VARS worked, however I agree with previous mentions about this being confusing. I spent time trying to diagnose login for multiple environments. But if it doesn't work, it should not be allowed as an option.

Most twilio sponsored workflows recommend usage of twilio login, so I am sure I will not be the last to run into this and get sidetracked.

childish-sambino pushed a commit to twilio/twilio-cli-core that referenced this issue Jun 16, 2020
If you've not created a profile yet and attempt to run a command that requires auth, you would see that the profile "undefined" could not be found. This change just updates the wording to indicate that a profile could not be found to use.

Relates to twilio/twilio-cli#148
@childish-sambino
Copy link
Contributor

Note that there was an issue in some twilio-cli releases prior to 2.2.0 that resulted in the Secure credential storage failed to load error. Also note that some of this is common code which is shared between twilio-cli and plugins. So even though twilio-cli resolved the issue, the plugin may be using old code. But I don't think that's the case here. Just tried on my local Windows 10 box and saw no issues using a fresh install with the latest twilio-cli release.

I've attempted several times to make credential use/storage in twilio-cli clear, but obviously have failed. I'm open to suggestions on how to make this more intuitive.

A native secure credential storage is not available on all environments. When twilio-cli attempts to interact with the store and fails, it prints a message explaining this and instructions about the use of env vars. We want guides/blogs to continue to use this path (via twilio login) as it's a better UX to use a CLI profile instead of env vars. So, fail if a profile can't be used and provide instructions. But there's still several cases where people are getting confused at this point and I don't know how to help clarify the path forward.

childish-sambino pushed a commit to twilio/twilio-cli-core that referenced this issue Jun 16, 2020
If you've not created a profile yet and attempt to run a command that requires auth, you would see that the profile "undefined" could not be found. This change just updates the wording to indicate that a profile could not be found to use.

Relates to twilio/twilio-cli#148
@drewstaylor
Copy link

drewstaylor commented Jun 21, 2020

I have all of the environment variables sourced. No matter what none of the commands work

lsd@lsd:~ $ echo $TWILIO_ACCOUNT_SID
> {correct sid}
lsd@lsd:~ $ echo $TWILIO_API_KEY
> {correct api key}
lsd@lsd:~ $ echo $TWILIO_API_SECRET
> {correct api secret}

They straight up all return the correct value, however exactly NO twilio cli functions get passed the auth stage. How is this still an issue?

@childish-sambino
Copy link
Contributor

@drewstaylor What command are you running and can you post the debug output here (append -l debug to the command)?

@drewstaylor
Copy link

drewstaylor commented Jun 22, 2020

@drewstaylor What command are you running and can you post the debug output here (append -l debug to the command)?

@childish-sambino as stated above calling any Twilio-cli command will not pass auth

Check .env file:

$ cat .env
PORT=1323
NOMSU=/bin/nomsu

TWILIO_ACCOUNT_SID={my account sid}
TWILIO_API_KEY={my api key}
TWILIO_API_SECRET={my api secret}
TWILIO_CHAT_SERVICE_SID={my chat service id}
TWILIO_CHANNEL={my actual channel}
TWILIO_AUTH_TOKEN={my actual token}

Check .env settings:

lsd@lsd:~/slf2/schrodingers-cup/src/api * master$ echo $TWILIO_ACCOUNT_SID
{output correct}
lsd@lsd:~/slf2/schrodingers-cup/src/api * master$ echo $TWILIO_API_KEY
{output correct}
lsd@lsd:~/slf2/schrodingers-cup/src/api * master$ echo $TWILIO_API_SECRET
{output correct}

Call any twilio-cli command and the output always fails on the same error:

$ twilio api:chat:v2:services:channels:messages:create --service-sid {my service sid} --channel-sid {my channel sid} -l debug
[DEBUG] Config File: /home/lsd/.twilio-cli/config.json
 » 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.
[DEBUG] TwilioCliError: 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.
    at reportUnconfigured (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/base-commands/twilio-client-command.js:28:13)
    at NewCommandClass.run (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/node_modules/@twilio/cli-core/src/base-commands/twilio-client-command.js:35:7)
    at async NewCommandClass.run (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/src/base-commands/twilio-api-command.js:27:5)
    at async NewCommandClass._run (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)
    at async Config.runCommand (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/node_modules/@oclif/config/lib/config.js:172:9)
    at async Main.run (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/main.js:22:9)
    at async Main._run (/home/lsd/.nvm/versions/node/v14.3.0/lib/node_modules/twilio-cli/node_modules/@oclif/command/lib/command.js:43:20)

@childish-sambino
Copy link
Contributor

@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

@drewstaylor
Copy link

drewstaylor commented Jun 22, 2020

@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

lsd@lsd:~/slf2/schrodingers-cup/src/api * master$ twilio version
twilio-cli/2.3.0 linux-x64 node-v14.3.0
lsd@lsd:~/slf2/schrodingers-cup/src/api * master$ node -v
v14.3.0

Could using nodejs via NVM be the culprit of this issue?

@childish-sambino
Copy link
Contributor

Could using nodejs via NVM be the culprit of this issue?

Doubt it. That's what I use. Still looking though ...

@drewstaylor
Copy link

drewstaylor commented Jun 22, 2020

@childish-sambino appreciated, thank you :)

As a sanity check our server is using the same .env file for REST requests that POST succesfully (see here) so the settings in there should be correct

@childish-sambino
Copy link
Contributor

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

@drewstaylor
Copy link

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

That worked, thank you :)

@childish-sambino
Copy link
Contributor

PR to update the wording on the env var message to include the export/set command: twilio/twilio-cli-core#93

@thathurtabit
Copy link

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.

@mikemaccana
Copy link

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

@RAFH82
Copy link

RAFH82 commented Nov 30, 2020

I'm running a vagrant machine and have all my credentials inside a .env file in my app root directory, with twilio installed, etc. It does not see my env variables.... I'm lost. I keep getting the same error :
» Installing keytar ...
» Secure credential storage failed to load.

Why is it not seeing my variables?

@lsachs-twilio
Copy link

@RAFH82 Can you please confirm the OS version you are using?

@ilKhr
Copy link

ilKhr commented Jan 12, 2022

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

OPTION 1 (recommended)

export TWILIO_ACCOUNT_SID=your Account SID from twil.io/console
export TWILIO_API_KEY=an API Key created at twil.io/get-api-key
export TWILIO_API_SECRET=the secret for the API Key

OPTION 2

export TWILIO_ACCOUNT_SID=your Account SID from twil.io/console
export TWILIO_AUTH_TOKEN=your Auth Token from twil.io/console

❗Attention here❗
Once these environment variables are set, a twilio-cli profile is not required and you may skip the "login" step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting for feedback waiting for feedback from the submitter type: security known security issue
Projects
None yet
Development

No branches or pull requests