1
$\begingroup$

I have an IBM Quantum account. How can I save the IBM Quantum API token to local environment so that I can access services including real quantum systems, simulators and Qiskit Runtime programs on my local machine using Qiskit?

$\endgroup$

2 Answers 2

1
$\begingroup$
  1. Create an IBM Quantum account or log in to your existing account by visiting the IBM Quantum login page.

  2. Copy (and/or optionally regenerate) your API token from your IBM Quantum account page.

  3. Take your token from step 2, here called MY_API_TOKEN, and run:

    from qiskit import IBMQ
    IBMQ.save_account('MY_API_TOKEN')
    

    The command above stores your credentials locally in a configuration file called qiskitrc. By default, this file is located in $HOME/.qiskit, where $HOME is your home directory. If you are still using Qconfig.py, please delete that file and run the command above.

See more info here: https://github.com/Qiskit/qiskit-ibmq-provider#setting-up-the-ibm-quantum-provider

$\endgroup$
1
$\begingroup$

I personally utilize python Keyring package for storing and retrieving the secrets on local OS. It leverages the OS provided security and supports mac, windows and linux os backends. This prevents the storage of secrets into plain text and makes notebooks portable.

If you are on windows os, you can store the credentials into windows credential manager and retrieve it using the keyring.

import keyring

# store username & password
keyring.set_password("my_ibmq_token", "username", "thetoken")

# retrieve username & password
username = keyring.get_password("my_ibmq_token", "username")
password = keyring.get_password("my_ibmq_token", "password")
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.