Support "integration" tokens

Integration tokens are different than OAuth token in it that they don't report any `X-Oauth-Scopes` in response headers.
This commit is contained in:
Mislav Marohnić 2020-10-16 16:56:23 +00:00 committed by GitHub
parent 626be2a095
commit 53cea2667e
2 changed files with 10 additions and 0 deletions

View file

@ -196,6 +196,11 @@ func (c Client) HasMinimumScopes(hostname string) error {
}
scopesHeader := res.Header.Get("X-Oauth-Scopes")
if scopesHeader == "" {
// if the token reports no scopes, assume that it's an integration token and give up on
// detecting its capabilities
return nil
}
search := map[string]bool{
"repo": false,

View file

@ -111,6 +111,11 @@ func Test_HasMinimumScopes(t *testing.T) {
header string
wantErr string
}{
{
name: "no scopes",
header: "",
wantErr: "",
},
{
name: "default scopes",
header: "repo, read:org",