Skip to content

Consider CLI for saving account #2054

@frankharkins

Description

@frankharkins

Context

We have a problem with users storing their account tokens in their source code or Jupyter notebook. We're currently writing a guide explaining that you shouldn't do this, but we could probably avoid the situation without additional documentation if we improve the user experience.

A pretty common approach to save user accounts is a CLI. Benefits to user are:

  • Less documentation reading needed; they just run a command that guides them through setting up their account
  • No temptation to leave token in source code or Jupyter notebook
  • Token isn't saved to REPL history

What is the expected feature or enhancement?

A CLI to save your account, made available on install.

Workflow would be along these lines:

  1. User runs command such as:
    $ qiskit-runtime-save-account
    
  2. CLI asks whether to use platform or cloud
  3. CLI prompts for token
  4. CLI prompts again for group and hub. If you wanted to get fancy you could work out which ones they have access to and provide them as options, but just entering the string is fine.
  5. Finally, we write this to file and explain it to the user.

The process could look something like:

$ qiskit-runtime-save-account
Would you like to use (1) ibm_quantum or (2) ibm_cloud?
Type the number and press enter (default ibm_quantum) 1
Using ibm_quantum
Please enter your IBM Quantum token, you can get this from https://quantum.ibm.com/
Please enter the instance you'd like to use (default ibm-q/open/main)
Account saved to ~/.qiskit/qiskit-ibm.json
⚠️ Note your token is saved to disk in plain text. If on a shared computer, make sure to regenerate your token when you're finished.

This CLI can easily be created using built-in Python functionality.

The original .save_account() method can still be public, we'd just recommend the CLI as a better user experience.

Acceptance criteria

Super simple CLI that guides a user through getting account information and saves it to disk. CLI should explain where the information is saved and that it's in plain text.

Nice to have:

  • Select from available options (e.g. we could show the user their available instances and have them enter the list number of the one they want)
  • Choose storing to environment variables rather than disk (if they're using a shared computer and want variables to disappear after their session).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions