X Tutup
Skip to content

Commit 14ce1f9

Browse files
committed
Ask for an additional read:org OAuth scope
This is to facilitate: - requesting teams for review on `pr create` - allowing `repo create ORG/REPO --team TEAM`
1 parent 82bd7b9 commit 14ce1f9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

auth/oauth.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"net/http"
1212
"net/url"
1313
"os"
14+
"strings"
1415

1516
"github.com/cli/cli/pkg/browser"
1617
)
@@ -29,6 +30,7 @@ type OAuthFlow struct {
2930
Hostname string
3031
ClientID string
3132
ClientSecret string
33+
Scopes []string
3234
WriteSuccessHTML func(io.Writer)
3335
VerboseStream io.Writer
3436
}
@@ -45,11 +47,15 @@ func (oa *OAuthFlow) ObtainAccessToken() (accessToken string, err error) {
4547
}
4648
port := listener.Addr().(*net.TCPAddr).Port
4749

50+
scopes := "repo"
51+
if oa.Scopes != nil {
52+
scopes = strings.Join(oa.Scopes, " ")
53+
}
54+
4855
q := url.Values{}
4956
q.Set("client_id", oa.ClientID)
5057
q.Set("redirect_uri", fmt.Sprintf("http://127.0.0.1:%d/callback", port))
51-
// TODO: make scopes configurable
52-
q.Set("scope", "repo")
58+
q.Set("scope", scopes)
5359
q.Set("state", state)
5460

5561
startURL := fmt.Sprintf("https://%s/login/oauth/authorize?%s", oa.Hostname, q.Encode())

context/config_setup.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ func setupConfigFile(filename string) (*configEntry, error) {
3636
Hostname: oauthHost,
3737
ClientID: oauthClientID,
3838
ClientSecret: oauthClientSecret,
39+
Scopes: []string{"repo", "read:org"},
3940
WriteSuccessHTML: func(w io.Writer) {
4041
fmt.Fprintln(w, oauthSuccessPage)
4142
},

0 commit comments

Comments
 (0)
X Tutup