github-app-token: Generate an installation access token for a GitHub App

[ http, library, mit ] [ Propose Tags ]

Please see README.md


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.0.1, 0.0.1.1, 0.0.1.2, 0.0.2.0, 0.0.3.0
Change log CHANGELOG.md
Dependencies aeson (>=2.0.3.0), base (>=4.16.4.0 && <5), bytestring (>=0.11.4.0), http-conduit (>=2.3.8.1), http-types (>=0.12.3), jwt (>=0.11.0), path (>=0.9.2), text (>=1.2.5.0), time (>=1.11.1.1), unliftio (>=0.2.25.0) [details]
License MIT
Author
Maintainer Freckle Education
Category HTTP
Home page https://github.com/freckle/github-app-token#readme
Bug tracker https://github.com/freckle/github-app-token/issues
Source repo head: git clone https://github.com/freckle/github-app-token
Uploaded by PatrickBrisbin at 2024-09-18T21:54:46Z
Distributions
Downloads 55 total (55 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-09-18 [all 1 reports]

Readme for github-app-token-0.0.1.1

[back to package description]

GitHub App Token

Hackage Stackage Nightly Stackage LTS CI

Generate an installation access token for a GitHub App

Usage

import Prelude

import Control.Lens ((^?))
import Data.Aeson.Lens
import Data.ByteString.Char8 qualified as BS8
import Data.Text.Encoding (encodeUtf8)
import GitHub.App.Token
import Network.HTTP.Simple
import Network.HTTP.Types.Header (hAccept, hAuthorization, hUserAgent)
import System.Environment

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"

CHANGELOG | LICENSE