From b2c6992e84e75bebc1265e1727f7c3b8b18d900c Mon Sep 17 00:00:00 2001 From: Nikola Jokic Date: Fri, 21 Jun 2024 12:10:56 +0200 Subject: [PATCH] Check status code of fetch access token for github app (#3568) --- github/actions/client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/github/actions/client.go b/github/actions/client.go index 18a078cf..2824f792 100644 --- a/github/actions/client.go +++ b/github/actions/client.go @@ -1054,6 +1054,14 @@ func (c *Client) fetchAccessToken(ctx context.Context, gitHubConfigURL string, c } defer resp.Body.Close() + if resp.StatusCode != http.StatusCreated { + return nil, &GitHubAPIError{ + StatusCode: resp.StatusCode, + RequestID: resp.Header.Get(HeaderGitHubRequestID), + Err: fmt.Errorf("failed to get access token for GitHub App auth: %v", resp.Status), + } + } + // Format: https://docs.github.com/en/rest/apps/apps#create-an-installation-access-token-for-an-app var accessToken *accessToken if err = json.NewDecoder(resp.Body).Decode(&accessToken); err != nil {