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?


2 Answers 2

  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

    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


You can use python Keyring package for storing and retrieving the secrets on local OS. It leverages the OS provided security and supports mac, windows and linux. This avoids token leak into plain text and notebooks.

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

Storing token: (One time)
import keyring
keyring.set_password("IBMQ", "ibmq-token", "the-token-goes-here")
Retrieve token:
retrieved_token = keyring.get_password("IBMQ", "ibmq-token")

Then perform login:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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