There are a few reasons you may want to update or add a new token to the Leap IDE.
- You upgraded your account to get more time and, as a result, have a new token
- You reset your token on the Dashboard
- You have multiple tokens
The Leap IDE automatically loads your API token into its environment variables. Any time you submit a problem to a solver, the solver will look in the environment variables for your token. If you don't have the correct token you won't be able to submit problems.
There are a couple ways to change your token in the environment variables. We suggest using the following command in the terminal:
gp env DWAVE_API_TOKEN=your_new_token
To check that the environment variable was correctly updated, use the command
That will print out a list of all your environment variables. When you use this command to change your API token the change takes effect immediately, so the next problem you send will use your new token.
To add an additional token, you can use the above command like this:
gp env SECOND_API_TOKEN=your_other_token
If you want to submit problems with this token you will need to import it into your python code and submit it to the sampler you use. Here's a small example
from dwave.system import DWaveSampler
second_token = os.getenv("SECOND_API_TOKEN")
sampler = DWaveSampler(token=second_token)
If you don't feel comfortable using the command line there is another option. Go to your Workspaces and click on your user name. Then choose 'Environment Variables.'
You will notice that there are two default variables: DWAVE_API_TOKEN and DWAVE_API_SOLVER. Copy your new token from the Dashboard and paste it into the DWAVE_API_TOKEN value field. Make sure to save it. If you have any running workspaces you will need to stop and restart them for the changes to take affect.
You can add additional tokens or environment variables here as well. As mentioned above, you will need to import any additional tokens into your python code in order to submit problems with them.