Skip to content

Commit 61f0f95

Browse files
authored
Merge pull request #61984 from cbippley/OSDOCS-6442
/lgtm, merging thanks!
2 parents 0f44146 + 03ed0ba commit 61f0f95

File tree

4 files changed

+84
-1
lines changed

4 files changed

+84
-1
lines changed

cli_reference/openshift_cli/getting-started-cli.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ include::modules/cli-installing-cli-brew.adoc[leveloffset=+2]
4040
// Logging in to the CLI
4141
include::modules/cli-logging-in.adoc[leveloffset=+1]
4242

43+
// Logging in to the CLI by using the web
44+
include::modules/cli-logging-in-web.adoc[leveloffset=+1]
45+
4346
// Using the CLI
4447
include::modules/cli-using-cli.adoc[leveloffset=+1]
4548

modules/cli-logging-in-web.adoc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * cli_reference/openshift_cli/getting-started.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="cli-logging-in-web_{context}"]
7+
= Logging in to the OpenShift CLI using a web browser
8+
9+
You can log in to the OpenShift CLI (`oc`) with the help of a web browser to access and manage your cluster. This allows users to avoid inserting their access token into the command line.
10+
11+
[WARNING]
12+
====
13+
Logging in to the CLI through the web browser runs a server on localhost with HTTP, not HTTPS; use with caution on multi-user workstations.
14+
====
15+
16+
.Prerequisites
17+
18+
* You must have access to an {product-title} cluster.
19+
* You must have installed the OpenShift CLI (`oc`).
20+
* You must have a browser installed.
21+
22+
.Procedure
23+
24+
. Enter the `oc login` command with the `--web` flag:
25+
+
26+
[source,terminal]
27+
----
28+
$ oc login <cluster_url> --web <1>
29+
----
30+
<1> If needed, you can specify the callback port and server URL.
31+
32+
. The web browser opens automatically. If it does not, click the link in the command output. If you do not specify the {product-title} server `oc` tries to open the web console of the cluster specified in the current `oc` configuration file. If no `oc` configuration exists, `oc` prompts interactively for the server URL.
33+
+
34+
.Example output
35+
36+
[source,terminal]
37+
----
38+
Opening login URL in the default browser: https://openshift.example.com
39+
Opening in existing browser session.
40+
----
41+
+
42+
.Example
43+
44+
[source,terminal]
45+
----
46+
$ oc login <https://api.your-openshift-server.com> --web --callback-port 8280 localhost:8443
47+
----
48+
. If more than one identity provider is available, select your choice from the options provided.
49+
50+
. Enter your username and password into the corresponding browser fields. After you are logged in, the browser displays the text `access token received successfully; please return to your terminal`.
51+
52+
. Check the CLI for a login confirmation.
53+
+
54+
.Example output
55+
56+
[source,terminal]
57+
----
58+
Login successful.
59+
60+
You don't have any projects. You can try to create a new project, by running
61+
62+
oc new-project <projectname>
63+
64+
----
65+
66+
[NOTE]
67+
====
68+
The web console defaults to the profile used in the previous session. To switch between Administrator and Developer profiles, log out of the {product-title} web console and clear the cache.
69+
====
70+
71+
You can now create a project or issue other commands for managing your cluster.

modules/getting-started-cli-login.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ You can log in to the OpenShift CLI (`oc`) to access and manage your cluster.
1515
1616
.Procedure
1717

18-
* Log into {product-title} from the CLI using your username and password or with an OAuth token:
18+
* Log into {product-title} from the CLI using your username and password, with an OAuth token, or with a web browser:
1919
** With username and password:
2020
+
2121
[source,terminal]
@@ -28,5 +28,11 @@ $ oc login -u=<username> -p=<password> --server=<your-openshift-server> --insecu
2828
----
2929
$ oc login <https://api.your-openshift-server.com> --token=<tokenID>
3030
----
31+
** With a web browser:
32+
+
33+
[source,terminal]
34+
----
35+
$ oc login <cluster_url> --web
36+
----
3137
3238
You can now create a project or issue other commands for managing your cluster.

modules/oauth-default-clients.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ The following OAuth clients are automatically created when starting the {product
1818
|`openshift-challenging-client`
1919
|Requests tokens with a user-agent that can handle `WWW-Authenticate` challenges.
2020

21+
|`openshift-cli-client`
22+
| Requests tokens by using a local HTTP server fetching an authorization code grant.
23+
2124
|===
2225
[.small]
2326
--

0 commit comments

Comments
 (0)