Hi everyone,
I am trying to download some data from synapse.org in my linux cluster. However, after the first successful login, I accidentally deleted the Personal Access Token I generated for the first login. Now, despite generating new Personal Access Tokens multiple times and uninstalling and reinstalling synapseclient, I can no longer log in via both command and python.
The following is my code and error message:
$ synapse login -u "Elliot_Liu"
Auth token for user Elliot_Liu:
SynapseAuthenticationError: You are not logged in and do not have access to a requested resource.
caused by SynapseHTTPError: 401 Client Error:
Invalid access token
I know that the token used to log in is a long string of characters generated on the website. But no matter how I generate a new one, I can't log in successfully. This confuses me greatly. I guess it may be because .synapseConfig has recorded the token for the first login, but I deleted and reinstalled synapseclient, and this method still doesn't work for me.
Has anyone encountered the same problem? Thank you very much for your help and reply
Best,
Elliot
Created by Jiahui Liu Elliot_Liu Thank you so much! I have solved this problem when I used your code!
Best,
Elliot Have you tried running:
```
synapse login -p $SYNAPSE_AUTH_TOKEN
```
to specify the auth token in your environment variables to log in? You should not need to specify your username with `-u` if you are using an auth token.
If you are using the activated Conda environment when you run `synapse` commands, I believe it should be using the file that you found. Just to be sure though, if the method above doesn't work check to see if there is another `.synapseConfig` file in the home directory on your machine.
Hi @bwmac ,
Thank you for your reply. For the manually editing the .sysnapseConfig file, since I used Miniconda to manage my environment, so I found the .sysnapseConfig file in /miniconda3/envs/synapseclient/lib/python3.9/site-packages/home/runner folder. I edited this file below:
```
###########################
# Login Credentials #
###########################
## Used for logging in to Synapse. See https://python-docs.synapse.org/tutorials/authentication/
## for information on retrieving an auth token.
#[authentication]
#username =
authtoken = xxxxxxxxxxxxxx (my new token)
```
Then, I tried to re-login my account which also required me to type my token and generated the same output and error message.
$ synapse login -u "Elliot_Liu"
Auth token for user Elliot_Liu:
SynapseAuthenticationError: You are not logged in and do not have access to a requested resource.
caused by SynapseHTTPError: 401 Client Error:
Invalid access token
In addition, I tried the second method in https://python-docs.synapse.org/tutorials/authentication/ Use Environment Variable section to re-login. It still cannot work and get the same error.
Since I used Conda to manage the environment, do you think there may be more .sysnapseConfig files in my system to interference my login process?
Best,
Elliot
Hi @Elliot_Liu,
Have you tried manually editing the .synapseConfig file and adding your new Authentication Token? Alternatively, you can set an environment variable in your system called `SYNAPSE_AUTH_TOKEN` with the string value of your new token like so:
```
export SYNAPSE_AUTH_TOKEN=''
```
Here is a link to the documentation around authentication for the Synapse Python Client/CLI: https://python-docs.synapse.org/tutorials/authentication/
Please let me know if you are still unable to authenticate after reviewing this information.
Brad Macdonald
Drop files to upload
Login issue with invalid access token page is loading…