Skip to content

Commit 6283c67

Browse files
committed
Ask for a token, not a password
According to [this comment][ref], the usage of a password is currently broken but it is possible to pass an access token instead. This access token is then stored in the configuration file, so adjust the message to ask for an access token, tell the user where then can generate a new one, provide the required scope, and do not tell that the value is not stored. [ref]: #2655 (comment)
1 parent e7576e0 commit 6283c67

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

features/authentication.feature

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Feature: OAuth authentication
2626
When I type "mislav"
2727
And I type "kitty"
2828
Then the output should contain "github.com username:"
29-
And the output should contain "github.com password for mislav (never stored):"
29+
And the output should contain "github.com access token with scope 'repo' for mislav (generate one at https://github.com/settings/tokens):"
3030
And the exit status should be 0
3131
And the file "~/.config/hub" should contain "user: MiSlAv"
3232
And the file "~/.config/hub" should contain "oauth_token: OTOKEN"
@@ -159,7 +159,7 @@ Feature: OAuth authentication
159159
Given $GITHUB_USER is "mislav"
160160
And $GITHUB_PASSWORD is "kitty"
161161
When I successfully run `hub create`
162-
Then the output should not contain "github.com password for mislav"
162+
Then the output should not contain "github.com access token with scope 'repo' for mislav"
163163
And the file "../home/.config/hub" should contain "oauth_token: OTOKEN"
164164

165165
Scenario: XDG: legacy config found, credentials from GITHUB_USER & GITHUB_PASSWORD
@@ -371,7 +371,7 @@ Feature: OAuth authentication
371371
When I type "mislav"
372372
And I type "kitty"
373373
And I type "112233"
374-
Then the output should contain "github.com password for mislav (never stored):"
374+
Then the output should contain "github.com access token with scope 'repo' for mislav (generate one at https://github.com/settings/tokens):"
375375
Then the output should contain "two-factor authentication code:"
376376
And the output should not contain "warning: invalid two-factor code"
377377
And the exit status should be 0
@@ -429,7 +429,7 @@ Feature: OAuth authentication
429429
When I run `hub create` interactively
430430
When I type "[email protected]"
431431
And I type "my pass@phrase ok?"
432-
Then the output should contain "github.com password for [email protected] (never stored):"
432+
Then the output should contain "github.com access token with scope 'repo' for [email protected] (generate one at https://github.com/settings/tokens):"
433433
And the exit status should be 0
434434
And the file "../home/.config/hub" should contain "user: mislav"
435435
And the file "../home/.config/hub" should contain "oauth_token: OTOKEN"
@@ -457,7 +457,7 @@ Feature: OAuth authentication
457457
When I run `hub fork` interactively
458458
And I type "mislav"
459459
And I type "kitty"
460-
Then the output should contain "git.my.org password for mislav (never stored):"
460+
Then the output should contain "git.my.org access token with scope 'repo' for mislav (generate one at https://git.my.org/settings/tokens):"
461461
And the exit status should be 0
462462
And the file "../home/.config/hub" should contain "git.my.org"
463463
And the file "../home/.config/hub" should contain "user: mislav"

github/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (c *Config) PromptForPassword(host, user string) (pass string) {
165165
return
166166
}
167167

168-
ui.Printf("%s password for %s (never stored): ", host, user)
168+
ui.Printf("%s access token with scope 'repo' for %s (generate one at https://%s/settings/tokens): ", host, user, host)
169169
if ui.IsTerminal(os.Stdin) {
170170
if password, err := getPassword(); err == nil {
171171
pass = password

0 commit comments

Comments
 (0)