`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.
* 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>
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.
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".
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>