X Tutup
Skip to content

Commit 53cea26

Browse files
authored
Support "integration" tokens
Integration tokens are different than OAuth token in it that they don't report any `X-Oauth-Scopes` in response headers.
1 parent 626be2a commit 53cea26

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

api/client.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ func (c Client) HasMinimumScopes(hostname string) error {
196196
}
197197

198198
scopesHeader := res.Header.Get("X-Oauth-Scopes")
199+
if scopesHeader == "" {
200+
// if the token reports no scopes, assume that it's an integration token and give up on
201+
// detecting its capabilities
202+
return nil
203+
}
199204

200205
search := map[string]bool{
201206
"repo": false,

api/client_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ func Test_HasMinimumScopes(t *testing.T) {
111111
header string
112112
wantErr string
113113
}{
114+
{
115+
name: "no scopes",
116+
header: "",
117+
wantErr: "",
118+
},
114119
{
115120
name: "default scopes",
116121
header: "repo, read:org",

0 commit comments

Comments
 (0)
X Tutup