Skip to content

Commit 6609c46

Browse files
committed
fix: use the correct github token getting membership info
1 parent cdfab4d commit 6609c46

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

internal/github/client.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,21 @@ func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, err
179179

180180
// GetAppSlug fetches the GitHub App slug identifier.
181181
// used to detect changes made by the app itself.
182+
// requires JWT authentication (not installation token).
182183
func (c *Client) GetAppSlug(ctx context.Context) (string, error) {
183-
if err := c.ensureValidToken(ctx); err != nil {
184-
return "", err
184+
jwtToken, err := c.createJWT()
185+
if err != nil {
186+
return "", errors.Wrap(err, "failed to create jwt for app slug fetch")
187+
}
188+
189+
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: jwtToken})
190+
tc := oauth2.NewClient(ctx, ts)
191+
appClient := github.NewClient(tc)
192+
if c.baseURL != "" {
193+
appClient.BaseURL, _ = appClient.BaseURL.Parse(c.baseURL)
185194
}
186195

187-
app, _, err := c.client.Apps.Get(ctx, "")
196+
app, _, err := appClient.Apps.Get(ctx, "")
188197
if err != nil {
189198
return "", errors.Wrapf(err, "failed to fetch app info for app id %d", c.appID)
190199
}

0 commit comments

Comments
 (0)