You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Note that a token must minimally have the **view** scope to be used with the Synapse Python Client.
11
11
* Include **Download** and **Modify** permissions if you are using the Synapse Python Client to follow any subsequent tutorials.
@@ -20,7 +20,6 @@ Use the [synapseclient.login][synapseclient.Synapse.login] function
20
20
```python
21
21
import synapseclient
22
22
syn = synapseclient.login(authToken="authtoken")
23
-
#returns Welcome, First Last!
24
23
```
25
24
26
25
### Command Line Client
@@ -39,133 +38,43 @@ Logged in as: username (1234567)
39
38
40
39
For writing code using the Synapse Python client that is easy to share with others, please do not include your credentials in the code. Instead, please use the `~/.synapseConfig` file to manage your credentials.
41
40
42
-
The Synapse Python Client supports multiple profiles within the `~/.synapseConfig` file, enabling users to manage credentials for multiple accounts. Each profile is defined in its own `[profile <profile_name>]` section. A default profile can still be defined using `[default]`.
43
-
44
41
When installing the Synapse Python client, the `~/.synapseConfig` is added to your home directory.
45
42
46
43
### Automatically modifying the `~/.synapseConfig` file with the Command line Client
47
44
You may modify the `~/.synapseConfig` file by utilizing the [command line client command and following the interactive prompts](./command_line_client.md#config):
48
45
49
-
#### Modifying the synapse config for multiple profiles
50
-
51
46
<!-- termynal -->
52
47
```
53
48
> synapse config
54
-
55
-
Synapse username (Optional): $MY_USERNAME
56
-
57
-
Auth token: $MY_SYNAPSE_TOKEN
58
-
59
-
Configuration profile name (Optional, 'default' used if not specified): $MY_CONFIG_PROFILE
60
-
```
61
-
62
-
#### Adding or updating a specific profile passed in as a command line argument
63
-
<!-- termynal -->
64
-
```
65
-
> synapse --profile $MY_PROFILE_NAME config
66
-
67
-
Synapse username (Optional): $MY_USERNAME
49
+
Synapse username (Optional):
68
50
69
51
Auth token: $MY_SYNAPSE_TOKEN
70
52
```
71
53
72
-
Note: If you encounter a PermissionError
73
-
(e.g., `[Errno 13] Permission denied: '/Users/username/.synapseConfig'`), it is likely that the user does not have write permissions to the `~/.synapseConfig` file.
74
-
To resolve this, ensure that you have the necessary permissions to modify this file.
75
-
You can change the permissions using the following command:
76
-
77
-
`chmod u+w ~/.synapseConfig`
78
-
79
-
80
54
### Manually modifying the `~/.synapseConfig` file
81
55
The following describes how to add your credentials to the `~/.synapseConfig` file without the use of the `synapse config` command.
82
56
83
-
Open the `~/.synapseConfig` file using your preferred text editing tool and find/insert the following section(s):
57
+
Open the `~/.synapseConfig` file and find the following section:
84
58
85
59
```
86
-
[default]
87
-
username = default_user
88
-
authtoken = default_auth_token
89
-
90
-
[profile user1]
91
-
username = user1
92
-
authtoken = user1_auth_token
93
-
94
-
[profile user2]
95
-
username = user2
96
-
authtoken = user2_auth_token
97
-
98
-
# This section is deprecated. It will be used if a `default` profile or a specific profile is not present in the config file
99
60
#[authentication]
100
-
#username = default_user
101
-
#authtoken = default_auth_token
61
+
#username = <username>
62
+
#authtoken = <authtoken>
102
63
```
103
64
104
-
`username` is optional when using `authtoken`, but if provided, an additional check to verify the `authtoken` matches the `username` is performed.
105
-
106
-
The `authoken` is also know as a personal access token. It is generated from your [synapse.org Settings](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens)..
107
-
108
-
### Transitioning from One Profile to Multiple
109
-
110
-
If you're currently using a single profile (under the `[default]` or `[authentication]` section) and wish to start using multiple profiles,
111
-
simply add new sections for each profile with a unique profile name. For example, you can add a profile for user1 and user2 as shown below.
112
-
The Synapse Python client will allow you to choose which profile to use at login.
113
-
65
+
To enable this section, uncomment it. You don't need to specify your username when using authtoken as a pair, but if you do, it will be used to verify your identity. A personal access token generated from your synapse.org Settings can be used as your .synapseConfig authtoken.
114
66
```
115
-
[default]
116
-
username = default_user
117
-
authtoken = default_auth_token
118
-
119
-
[profile user1]
120
-
username = user1
121
-
authtoken = user1_auth_token
122
-
123
-
[profile user2]
124
-
username = user2
125
-
authtoken = user2_auth_token
67
+
[authentication]
68
+
authtoken = <authtoken>
126
69
```
127
70
128
-
## Logging in with your ~/.synapseConfig file
129
-
130
-
**Note:** If no profile is specified the `default` section will be used. Additionally, to support backwards compatibility, `authentication` will continue to function. `authentication` will be used if no profile is used and `default` is not present in the configuration file.
131
-
132
-
### Logging in via python code
71
+
Now, you can login without specifying any arguments:
133
72
134
73
```python
135
74
import synapseclient
136
75
syn = synapseclient.login()
137
76
```
138
77
139
-
If you want to log in with a specific profile, simply pass the profile name as an argument to `login()`:
140
-
141
-
```python
142
-
import synapseclient
143
-
syn = synapseclient.login(profile="user1")
144
-
```
145
-
146
-
### Logging in via the command line
147
-
148
-
Logs in with the `default` profile, or the profile set in the `SYNAPSE_PROFILE` environment variable:
149
-
150
-
<!-- termynal -->
151
-
```
152
-
#For default login
153
-
> synapse login
154
-
155
-
returns Welcome, last first!
156
-
```
157
-
158
-
Logging in with the `profile_name` given:
159
-
160
-
<!-- termynal -->
161
-
```
162
-
#For profile login
163
-
164
-
> synapse --profile profile_name login
165
-
166
-
Welcome, last first! You are using the 'profile_name' profile.
167
-
```
168
-
169
78
## Use Environment Variable
170
79
171
80
Setting the `SYNAPSE_AUTH_TOKEN` environment variable will allow you to login to Synapse with a [Personal Access Token](https://help.synapse.org/docs/Managing-Your-Account.2055405596.html#ManagingYourAccount-PersonalAccessTokens)
@@ -178,26 +87,21 @@ In your shell, you can pass an environment variable to Python inline by defining
Setting the `SYNAPSE_PROFILE` environment variable will allow you to log into Synapse using a specific authentication profile present in your `.synapseConfig` file. This allows you to have multiple profiles present in a single configuration file that you may swap between. Alternatively, you may use the `profile` parameter in Python, or the `--profile` command line flag for all commands like `synapse --profile <profile_name> COMMAND`.
189
-
190
-
Once you are inside Python, you may simply login without passing any arguments, or pass a profile argument to access a specific profile:
97
+
Once you are inside Python, you may simply login without passing any arguments:
191
98
192
99
```python
193
100
import synapseclient
194
101
syn = synapseclient.login()
195
-
196
-
import synapseclient
197
-
syn = synapseclient.login(profile="user1")
198
102
```
199
103
200
-
To use the environment variable with the command line client, simply substitute `python` for the `synapse` command:
104
+
To use the environment variable with the command line client, simply substitute `python` for the `synapse` command
201
105
202
106
```bash
203
107
SYNAPSE_AUTH_TOKEN='<my_personal_access_token>' synapse get syn123
0 commit comments