From 53cea2667e58e5cbd3261d237b36aa42280094e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 16 Oct 2020 16:56:23 +0000 Subject: [PATCH] Support "integration" tokens Integration tokens are different than OAuth token in it that they don't report any `X-Oauth-Scopes` in response headers. --- api/client.go | 5 +++++ api/client_test.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/api/client.go b/api/client.go index b290aae3d..09195181b 100644 --- a/api/client.go +++ b/api/client.go @@ -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, diff --git a/api/client_test.go b/api/client_test.go index fd24a5404..35a45af8c 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -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",