Skip to content

Commit 22aff4b

Browse files
authored
Updated auth related notes for CLI in README
1 parent 5dac27b commit 22aff4b

File tree

1 file changed

+47
-20
lines changed

1 file changed

+47
-20
lines changed

README.md

Lines changed: 47 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,45 @@ When the module is installed, it comes with `mergin` command line tool.
3333
$ mergin --help
3434
Usage: mergin [OPTIONS] COMMAND [ARGS]...
3535
36+
Command line interface for the Mergin client module. For user
37+
authentication on server there are two options: 1. authorization token
38+
environment variable (MERGIN_AUTH) is defined, or 2. username and
39+
password need to be given either as environment variables
40+
(MERGIN_USERNAME, MERGIN_PASSWORD), or as command options (--username,
41+
--password). Run `mergin --username <your_user> login` to see how to set
42+
the token variable manually.
43+
3644
Options:
37-
--help Show this message and exit.
45+
--url TEXT Mergin server URL. Default is:
46+
https://public.cloudmergin.com
47+
--auth-token TEXT Mergin authentication token string
48+
--username TEXT
49+
--password TEXT
50+
--help Show this message and exit.
3851
3952
Commands:
40-
create Create a new project on Mergin server
41-
download Download last version of mergin project
42-
list-projects List projects on the server
43-
login Fetch new authentication token.
44-
modtime Show files modification time info.
45-
pull Fetch changes from Mergin repository
46-
push Upload local changes into Mergin repository
47-
remove Remove project from server and locally (if exists).
48-
status Show all changes in project files - upstream and local
53+
clone Clone project from server.
54+
create Create a new project on Mergin server.
55+
download Download last version of mergin project
56+
list-projects List projects on the server
57+
login Login to the service and see how to set the token...
58+
pull Fetch changes from Mergin repository
59+
push Upload local changes into Mergin repository
60+
remove Remove project from server.
61+
show-file-changeset Displays information about project changes.
62+
show-file-history Displays information about a single version of a...
63+
show-version Displays information about a single version of a...
64+
status Show all changes in project files - upstream and...
4965
```
5066

51-
To start using `mergin`, first run its "login" command to get authorization token:
67+
For example, to download a project:
5268

5369
```
54-
$ mergin login
70+
$ mergin --username john download john/project1 ~/mergin/project1
5571
```
5672

57-
It will ask for username and password and then output environment variables
58-
with authorization. The returned token is not permanent - it will expire after
59-
several hours. When the variables are set, it is possible to run other commands,
60-
for example, to download a project:
61-
62-
```
63-
$ mergin download username/project1 ~/mergin/project1
64-
```
73+
If you do not want to specify username on the command line and be asked for you password every time,
74+
it is possible to set env variables MERGIN_USERNAME and MERGIN_PASSWORD.
6575

6676
When a project is downloaded, `mergin` commands can be run in the project's
6777
working directory:
@@ -79,6 +89,23 @@ working directory:
7989
$ mergin push
8090
```
8191

92+
### Using CLI with auth token
93+
94+
If you plan to run `mergin` command multiple times and you wish to avoid logging in every time,
95+
you can use "login" command to get authorization token.
96+
It will ask for password and then output environment variable with auth token. The returned token
97+
is not permanent - it will expire after several hours.
98+
```
99+
$ mergin --username john login
100+
Password: topsecret
101+
Login successful!
102+
To set the MERGIN_AUTH variable run:
103+
export MERGIN_AUTH="Bearer ......."
104+
```
105+
106+
When the MERGIN_AUTH env variable is set (or passed with `--auth-token` command line argument),
107+
it is possible to run other commands without specifying username/password.
108+
82109

83110
## Development
84111

0 commit comments

Comments
 (0)