Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First implementaiton of github-app-token package #1

Merged
merged 15 commits into from
Sep 12, 2024
Merged

First implementaiton of github-app-token package #1

merged 15 commits into from
Sep 12, 2024

Conversation

pbrisbin
Copy link
Member

@pbrisbin pbrisbin commented Sep 11, 2024

Implements a library for going through these steps to mint an access token for an App installation.

README example:

example :: IO ()
example = do
  appId <- AppId . read <$> getEnv "GITHUB_APP_ID"
  privateKey <- PrivateKey . BS8.pack <$> getEnv "GITHUB_PRIVATE_KEY"
  installationId <- InstallationId . read <$> getEnv "GITHUB_INSTALLATION_ID"

  let creds = AppCredentials {appId, privateKey}
  token <- generateInstallationToken creds installationId

  req <- parseRequest "https://api.github.com/repos/freckle/github-app-token"
  resp <- httpLBS
    $ addRequestHeader hAccept "application/json"
    $ addRequestHeader hAuthorization ("Bearer " <> encodeUtf8 token.token)
    $ addRequestHeader hUserAgent "github-app-token/example"
    $ req

  print $ getResponseBody resp ^? key "description" . _String
  -- => Just "Generate an installation token for a GitHub App"

I put this in a github-app-token sub-directory, assuming I'll further wrap this in github-app-token-cli. I may abandon this idea though.

@pbrisbin pbrisbin changed the title pb/first First implementaiton of github-app-token package Sep 11, 2024
@restyled-io restyled-io bot mentioned this pull request Sep 11, 2024
@pbrisbin pbrisbin marked this pull request as ready for review September 11, 2024 17:08
@pbrisbin pbrisbin requested a review from danroyo September 12, 2024 13:00
@pbrisbin pbrisbin merged commit ec446da into main Sep 12, 2024
4 checks passed
@pbrisbin pbrisbin deleted the pb/first branch September 12, 2024 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants