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
Copy file name to clipboardExpand all lines: README.md
+35-23Lines changed: 35 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -103,54 +103,65 @@ See [Sourcegraph CLI for Windows](WINDOWS.md).
103
103
docker run --rm=true sourcegraph/src-cli:latest search 'hello world'
104
104
```
105
105
106
-
## Log intoyour Sourcegraph instance
106
+
<aid="log-into-your-sourcegraph-instance"></a>
107
107
108
-
Run <code><strong>src login <i>SOURCEGRAPH-URL</i></strong></code> to authenticate `src` to access your Sourcegraph instance with your user credentials.
108
+
## Connect to your Sourcegraph instance
109
109
110
-
<blockquote>
110
+
`src` needs the URL of your Sourcegraph instance. Set `SRC_ENDPOINT` in your shell environment, replacing `https://sourcegraph.example.com` with your instance URL:
-`SRC_ENDPOINT`: the URL to your Sourcegraph instance (such as `https://sourcegraph.example.com`)
121
-
-`SRC_ACCESS_TOKEN`: your Sourcegraph access token (on your Sourcegraph instance, click your user menu in the top right, then select **Settings > Access tokens** to create one)
122
+
For convenience, add this environment variable to your terminal profile or system environment variables. On Mac OS and Linux, the terminal profile is typically `~/.bash_profile` for Bash or `~/.zprofile` for Zsh. On Windows, you can add it through the *System Properties* window. See [these instructions](https://www.computerhope.com/issues/ch000549.htm) for details.
122
123
123
-
For convenience, you can add these environment variables persistently.
124
+
If `SRC_ENDPOINT` is not set, `src` defaults to `https://sourcegraph.com`.
124
125
125
-
### Configuration: Mac OS / Linux
126
+
### OAuth login
126
127
127
-
Add the following to your terminal profile file, typically accessible at `~/.bash_profile` (if using Bash) or `~/.zprofile` (if using Zsh):
128
+
Run `src login` to authenticate interactively with OAuth:
Replace `my-token` and `https://sourcegraph.example.com` with the appropriate values for your account and instance.
134
+
OAuth does not require you to create or export `SRC_ACCESS_TOKEN`. The OAuth credential is stored in your operating system's native keyring. Keep `SRC_ENDPOINT` set when running subsequent commands because `src` uses the endpoint to load the matching OAuth credential.
135
135
136
-
You can also inline them in a single command with:
136
+
You can also pass the instance URL directly to `src login`, but this only selects the endpoint for that login command. You must still set `SRC_ENDPOINT` when running subsequent commands:
To use the active credential in another command, `src auth token` prints the raw token and `src auth token --header` prints a complete `Authorization` header for the active authentication mode.
143
143
144
-
Type the following on your PowerShell terminal:
144
+
### Personal access token login
145
145
146
+
For non-interactive authentication, such as in CI or scripts, create an access token on your Sourcegraph instance under **Settings > Access tokens**, then set both `SRC_ENDPOINT` and `SRC_ACCESS_TOKEN`:
Replace `my-token` and `https://sourcegraph.example.com` with the appropriate values for your account and instance.
160
+
When `SRC_ACCESS_TOKEN` is set, `src` uses it instead of an OAuth credential and running `src login` is not necessary. You can also set both variables for a single command:
152
161
153
-
You can also manually add them via the *System Properties* windows. Check [this post](https://www.computerhope.com/issues/ch000549.htm) for details.
0 commit comments