Commit graph

332 commits

Author SHA1 Message Date
Fredric Silberberg
a656271f26 Print gh auth refresh for 401 returns
`gh auth refresh` exists to make it simpler for users to refresh their tokens on expiration/scope mismatch, but help messages only suggest using it in limited scenarios, and not in a common case of a token expiring and the user receiving a 401 error. Now, the auth flow will detect this case, and for refreshable tokens (namely, tokens created by logging in with `gh auth login` in the first place), it will suggest using `gh auth refresh` for these cases.
2026-04-20 12:07:14 -06:00
William Martin
3ed389d664 Disable telemetry for GHES 2026-04-17 11:50:24 +02:00
William Martin
18dc5e77f0 Add sampled command telemetry 2026-04-16 21:42:46 +02:00
Babak K. Shandiz
5685b9a443
refactor(auth refresh): use PlainHttpClient instead of zero http.Client
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-13 16:51:13 +01:00
Babak K. Shandiz
365ca1a901
refactor(auth login): use PlainHttpClient for OAuth flow
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-10-13 16:51:11 +01:00
Babak K. Shandiz
38d6a83e35
test(auth status): correctly replace JSON-escaped paths
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-25 10:51:47 +01:00
Babak K. Shandiz
e31136a677
docs(auth status): explain --json will always exit with zero
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-23 15:42:25 +01:00
Babak K. Shandiz
5fddcef0a8
fix(auth status): return JSON entries under hosts
Signed-off-by: Babak K. Shandiz <babakks@github.com>
2025-09-23 15:24:37 +01:00
Benjamin Levesque
914531e6f1
fixup! examples 2025-09-16 23:07:11 +02:00
Benjamin Levesque
4449af614c
fix error missing in json output 2025-09-16 23:00:41 +02:00
Benjamin Levesque
5bb76e832b
examples 2025-09-16 22:00:07 +02:00
Benjamin Levesque
3cdd359987
remove showToken from authEntry 2025-09-16 21:57:28 +02:00
Benjamin Levesque
e2df8ac1cc
address copilot comment on parameter order 2025-09-13 22:33:27 +02:00
Benjamin Levesque
5ae0410bd2
add examples 2025-09-13 22:25:20 +02:00
Benjamin Levesque
a69f7a6b53
simplify exporter usage 2025-09-13 22:14:59 +02:00
Benjamin Levesque
5abb467e69
remove includeScope 2025-09-13 21:50:06 +02:00
Benjamin Levesque
54bf8432f6
do not mutate opts.ShowToken 2025-09-13 21:35:02 +02:00
Benjamin Levesque
60088e0e7d
move displayToken to String method 2025-09-13 21:30:20 +02:00
Benjamin Levesque
b38e12ef61
move flag validation to RunE 2025-09-13 21:30:19 +02:00
Benjamin Levesque
45ecc5ece9
introduce AddJSONFlagsWithoutShorthand 2025-08-31 17:56:52 +02:00
Kynan Ware
e1a1040f37
Merge branch 'trunk' into auth-status-json-output-8635 2025-08-25 10:00:43 -06:00
Andrey
4e1318eb2a
feat: gh auth Automatically copy one-time OAuth code to clipboard (#11518)
* feat: add ability to copy one-time OAuth code while authenticating

Signed-off-by: Andrey <andrekabatareika@gmail.com>

* fix(docs): wrong example for gh auth refresh

* chore(authflow): update message to include one-time code to it

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore(authflow): improve message when copied one-time code

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* chore(authflow): don't early return error when could not copy OAuth code

Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>

* refactor(authflow): make code for working with OAuth code more readable

* Adjust language in `gh auth` help for clipboard

---------

Signed-off-by: Andrey <andrekabatareika@gmail.com>
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-08-25 09:52:51 -06:00
Benjamin Levesque
78675e73e1
fix show token when using json 2025-08-20 21:01:31 +02:00
Benjamin Levesque
48bc79a291
fix exit code 2025-08-20 20:26:27 +02:00
Benjamin Levesque
085f31fed8
revert showToken change 2025-08-20 20:07:57 +02:00
Benjamin Levesque
c937e0275d
mutually exclusive flags 2025-08-20 20:02:41 +02:00
Benjamin Levesque
faa0e2c26b
flag duplicate check 2025-08-20 20:02:00 +02:00
Benjamin Levesque
6e6c09e6b1
add ExpectCommandToSupportJSONFields 2025-08-20 19:36:09 +02:00
Benjamin Levesque
3d02e248c0
do not export authState 2025-08-20 17:50:29 +02:00
Benjamin Levesque
96755eec83
handle -t conflict 2025-08-20 09:05:20 +02:00
Benjamin Levesque
3ffe199ef3
do not fetch scope if not necessary 2025-08-20 01:04:09 +02:00
Benjamin Levesque
8b553d66cc
json flags 2025-08-20 00:27:31 +02:00
Benjamin Levesque
fd19da8e55
auth state enum 2025-08-19 23:43:22 +02:00
Benjamin Levesque
0091384495
Refactor entry to a single type 2025-08-19 22:54:31 +02:00
Benjamin Levesque
c5fc7e3ffb
Fix missing assertions 2025-08-19 22:37:25 +02:00
Andy Feller
29a94ab9b1 Reformat non-documentation hostnames
Outside of the hostnames previously fixed, I talked with @williammartin about what to do with the remaining references and the concern about the mixed format.

One suggestion for the error / test use case was to remove the extraneous text all together.
2025-07-14 08:43:15 -04:00
Azeem Sajid
33c30d5bd1 Inconsistent format of examples in help text 2025-02-27 16:26:25 +05:00
William Martin
f019cf7cea
Merge pull request #10501 from cli/wm/fix-minor-auth-login-help
Fix minor auth login help typo
2025-02-25 16:47:38 +01:00
William Martin
ac6ad78ff9 Fix minor auth login help typo 2025-02-25 12:27:30 +01:00
Kynan Ware
d68a4daa8c
docs: OAuth doc link moves to newline
Co-authored-by: Andy Feller <andyfeller@github.com>
2025-02-24 14:12:19 -07:00
Kynan Ware
736447cca4 docs: warn about process revoking all tokens 2025-02-23 18:24:28 +00:00
Kynan Ware
e2f382c44d docs: document how to revoke gh OAuth tokens
This documents how to revoke OAuth tokens generated by `gh`. This also
adjusts some language to match the language used by GitHub.com:
"invalidate" is now "revoke".
2025-02-23 18:12:06 +00:00
Tyler McGoffin
e047d4a611
Merge pull request #10429 from iamazeem/8404-standardize-urls
Standardize URLs
2025-02-13 10:49:18 -08:00
Tyler McGoffin
b4a90c15f9 Add missing <> in gh auth login docs 2025-02-13 10:38:21 -08:00
Azeem Sajid
8b7fb231ec Remove trailing whitespace 2025-02-13 11:06:27 +05:00
William Martin
0a3706a404 Remove unncessary printf usage 2025-01-21 18:04:47 +01:00
Mikel Olasagasti Uranga
4396e40a31 Fix: Ensure constant format strings in fmt and printf calls
Go 1.24 introduces stricter checks for format string validation.
This commit fixes instances where non-constant format strings were
used in calls to functions like `fmt.Errorf`, `fmt.Printf`, and similar.

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
2025-01-20 16:27:27 +01:00
William Martin
e7d49fb78c
Update pkg/cmd/auth/login/login.go
Co-authored-by: Andy Feller <andyfeller@github.com>
2025-01-06 17:21:02 +01:00
William Martin
3695bda637 Clear up --with-token fine grained PAT usage 2025-01-06 16:41:48 +01:00
Tyler McGoffin
aa793f1dac
Update pkg/cmd/auth/login/login.go
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
2025-01-02 14:22:20 -08:00