Refreshed token, can't ping

Back again and confused again.
After a month or two not accessing Xanadu, I programmatically refreshed the access token and on my Linux system the ~/.config/xanadu-cloud/.env file was updated.
But the test thereafter fails with

$ python
Python 3.10.4 (main, Apr  2 2022, 09:04:19) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xcc.commands
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jwoehr/work/Xanadu/xanadu_venv/lib/python3.10/site-packages/xcc/", line 311, in ping
  File "/home/jwoehr/work/Xanadu/xanadu_venv/lib/python3.10/site-packages/xcc/", line 211, in ping
    return self.request(method="GET", path="/healthz")
  File "/home/jwoehr/work/Xanadu/xanadu_venv/lib/python3.10/site-packages/xcc/", line 241, in request
  File "/home/jwoehr/work/Xanadu/xanadu_venv/lib/python3.10/site-packages/xcc/", line 313, in update_access_token
    raise requests.exceptions.HTTPError(
requests.exceptions.HTTPError: Refresh token (e.g., Xanadu Cloud API key) is invalid

I went to the cloud page, generated a new token, saved it programmatically. ping() and submitting jobs still doesn’t work.
However, in the cloud page, it shows that I did generate the token and use it: " Your API key was created on 6/1/2022, 9:18:11 PM and was last used on 6/1/2022, 9:18:11 PM (from", i.e., a few moments ago.

Hi @Jack_W,

Can you please confirm that you have the latest version of xcc (v0.2.1)?

Also, have you followed the steps here?

Hi @CatalinaAlbornoz
I have done this step:

import xcc
settings = xcc.Settings(REFRESH_TOKEN="Xanadu Cloud API key goes here") 

(of course substituting the API key I generated and copied from There is no error from that operation, and the file $HOME/.config/xanadu-cloud/.env is updated as a result of that operation.


$ xcc ping
ERROR: Refresh token (e.g., Xanadu Cloud API key) is invalid.

I also made sure to update with pip install strawberryfields --upgrade

$ xcc version
Xanadu Cloud Client version 0.2.1

Hmm, I just tried this:
xcc config set REFRESH_TOKEN "....."
And now I can ping
I guess somehow a bad character got in the way I did it programmatically in Python.

Weird, I’m playing with this, and I am reasonably sure I am feeding the same string in to my Python refresh token code as I do at the xcc command line, and yet the command line work and the Python program does not work. Both successfully alter the config file, but afterwards, only the xcc command line alteration generates a useful token.

Found it. There was indeed a superfluous lf (0x0a) in the string I was feeding to my Python code. Sheesh. Apologies for ringing the bell!

I’m glad you found the problem @Jack_W!

1 Like