@@ -9,9 +9,9 @@ and [retrieving](pub-get) dependencies.
9
9
10
10
It stores these tokens in a [ user-wide config directory] [ config-dir ] .
11
11
12
- It has three subcommands: ` add ` , ` list ` and ` remove ` .
12
+ This command consists of three subcommands: ` add ` , ` list ` and ` remove ` .
13
13
14
- Consider a scenario when you have a [ dependency] ( /tools/pub/dependencies )
14
+ Consider a scenario where you have a [ dependency] ( /tools/pub/dependencies )
15
15
hosted on a private repository.
16
16
When you invoke ` dart pub get ` , the command _ might_ return a prompt
17
17
to provide credentials:
@@ -25,16 +25,18 @@ https://some-package-repo.com/my-org/my-repo package repository requested authen
25
25
Go to https://some-package-repo.com and log in to obtain your token.
26
26
```
27
27
28
- In this last message, the final line gives you the server that can help you
29
- obtain a token. Not all servers provide such this message.
28
+ The server might include a message in the final line of the prompt
29
+ to help you obtain a token.
30
+ This message is displayed in the previous example.
31
+ Not all servers provide this message.
30
32
31
33
## Add a new credential
32
34
33
- To create a new credential, invoke ` dart pub token add ` .
35
+ To add a new credential, run the command ` dart pub token add ` .
34
36
35
37
### Add a credential for the current session
36
38
37
- At the prompt, type the credential on the command line ( ` stdin ` ) .
39
+ At the prompt, type the credential on the command line.
38
40
39
41
``` console
40
42
$ dart pub token add https://some-package-repo.com/my-org/my-repo
@@ -44,45 +46,34 @@ Enter secret token: <Type token on stdin>
44
46
```
45
47
46
48
::: note
47
- The token takes input on ` stdin ` rather than as a command line option
49
+ The token takes input over ` stdin ` rather than as a command line option
48
50
to keep the token out of the shell history.
49
51
:::
50
52
51
53
### Add a credential for all sessions
52
54
53
55
In a script, you can store the secret in an environment variable.
54
56
55
- If you choose to store your secret in an environment variable,
56
- find a way to hide the secret from your shell history.
57
- To explore one way of doing this, consult [ this post on Medium] [ zsh-post ] .
58
- If you add a local environment variable, you need to restart any open
57
+ If you choose to store your token in an environment variable,
58
+ [ find a way] [ zsh-post ] to hide the token from your shell history.
59
+ If you add an environment variable, you need to restart any open
59
60
consoles to enable that new variable.
60
61
61
- Most CI environments can inject secrets into an environment variable.
62
- To learn how, consult documentation for [ GitHub Actions] [ ]] or
62
+ Most CI environments can inject tokens into an environment variable.
63
+ To learn how, consult documentation for [ GitHub Actions] [ ] or
63
64
[ GitLab] [ ] as examples.
64
65
65
66
[ GitHub Actions ] : https://docs.github.com/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
66
67
[ GitLab ] : https://docs.gitlab.com/ee/ci/secrets/
67
68
[ zsh-post ] : https://medium.com/@prasincs/hiding-secret-keys-from-shell-history-part-1-5875eb5556cc
68
69
69
- To use an environment variable as a token, invoke:
70
70
71
- ``` console
72
- dart pub token add <hosted-url> --env-var <ENV_VAR_NAME>
73
- ```
74
71
75
- This causes ` dart pub get ` to read the data stored in ` $TOKEN_VAR ` then
76
- use it as the authentication token.
77
72
78
- ``` console
79
- $ dart pub token add https://other-package-repo.com/ --env-var TOKEN_VAR
80
- Requests to "https://other-package-repo.com/" will now be authenticated using the secret token stored in the environment variable "TOKEN_VAR".
81
- ```
82
73
83
74
## Return a list of credentials
84
75
85
- To see a list of all active credentials, invoke ` dart pub token list ` :
76
+ To see a list of all active credentials, run the command ` dart pub token list ` :
86
77
87
78
``` console
88
79
$ dart pub token list
@@ -93,14 +84,15 @@ https://other-package-repo.com/
93
84
94
85
## Remove one or more credentials
95
86
96
- To remove a single token, invoke ` dart pub token remove ` :
87
+ To remove a single token, run the command ` dart pub token remove ` :
97
88
98
89
``` console
99
90
$ dart pub token remove https://other-package-repo.com
100
91
Removed secret token for package repository: https://other-package-repo.com
101
92
```
102
93
103
- To remove all tokens, invoke the command with the ` remove --all ` option:
94
+ To remove all tokens,
95
+ run the same command and append the ` --all ` option:
104
96
105
97
``` console
106
98
$ dart pub token remove --all
0 commit comments