Skip to content

Commit

Permalink
aaaaa
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Oct 26, 2024
1 parent 0f3f980 commit 69af283
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions backend/cmd/gh-updater/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func main() {
os.Exit(1)
}

// FIXME: remove this!!!
slog.Debug("DEBUG: ", slog.Int64("GITHUB_APP_ID", githubAppID))
slog.Debug("DEBUG: ", slog.String("GITHUB_APP_PRIVATE_KEY_BASE64", privateKeyBase64))

rsaPrivateKey, err := jwt.ParseRSAPrivateKeyFromPEM(privateKey)
if err != nil {
slog.Error("error parsing GitHub App RSA private key from PEM", slog.Any("error", err))
Expand Down
6 changes: 5 additions & 1 deletion backend/cmd/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ func main() {
log.Fatalln("generate signed jwt:", err)
}

return

appClient := http.Client{Transport: &bearerTransport{Token: jwtString}}
gh := github.NewClient(&appClient)
res, _, err := gh.Apps.CreateInstallationToken(context.Background(), installationID, nil)
Expand All @@ -59,13 +61,15 @@ func generateSignedJWT(githubAppID int64, rsaPrivateKey *rsa.PrivateKey) (string
}

token := jwt.NewWithClaims(jwt.SigningMethodRS256, claims)
fmt.Printf("created a token: %#v\n", *token)
fmt.Printf("Created JWT struct: %#v\n\n", *token)

tokenStr, err := token.SignedString(rsaPrivateKey)
if err != nil {
return "", fmt.Errorf("sign jwt: %w", err)
}

fmt.Printf("generated signed JWT string: %s\n\n", tokenStr)

return tokenStr, nil
}

Expand Down

0 comments on commit 69af283

Please sign in to comment.