removeRejectedCredential removes the user's stored credential after the server rejected its refresh token, and records the outcome on attempt. secure tells whether the credential was read from the keyring. It deliberately returns no error. The removal is cleanup on a path that has already failed: t
(hostname, username string, secure bool, attempt *refreshAttempt)
| 652 | // point at the lost credential. After a failed removal, the rejected credential keeps being presented without the user |
| 653 | // knowing why. |
| 654 | func (c *AuthConfig) removeRejectedCredential(hostname, username string, secure bool, attempt *refreshAttempt) { |
| 655 | err := c.removeCredentialForUser(hostname, username, secure) |
| 656 | if err == nil { |
| 657 | attempt.outcome = refreshOutcomeRejectedRemoved |
| 658 | c.addWarning(fmt.Sprintf( |
| 659 | "The refresh token of account %s on %s was rejected, so gh removed the stored credential. "+ |
| 660 | "Run `gh auth login -h %s` to sign in again.", |
| 661 | username, hostname, hostname)) |
| 662 | return |
| 663 | } |
| 664 | attempt.outcome = refreshOutcomeRejectedRemoveFailed |
| 665 | attempt.storageError = refreshStorageErrorKind(err) |
| 666 | c.addWarning(fmt.Sprintf( |
| 667 | "The refresh token of account %s on %s was rejected, and gh could not remove the stored credential: %v. "+ |
| 668 | "Run `gh auth login -h %s` to sign in again. If gh is running in a sandbox, it may not be allowed to "+ |
| 669 | "modify the system keyring or gh's configuration directory; run the command outside of it.", |
| 670 | username, hostname, err, hostname)) |
| 671 | } |
| 672 | |
| 673 | // removeCredentialForUser deletes every stored credential record for the user on the host, covering both the |
| 674 | // refreshable and the non-expiring forms in both the keyring and the insecure config, then writes the config. It |
no test coverage detected