{"modulePath":"github.com/abcxyz/pkg","version":"v0.7.3","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package githubapp\n\nPackage githubapp contains a class with methods for any service that needs to interact with GitHub as an app.\n\n## Types\n\n```go\ntype Config struct {\n\tAppID          string\n\tInstallationID string\n\tPrivateKey     *rsa.PrivateKey\n\t// contains filtered or unexported fields\n}\n```\nConfig contains all of the required configuration for operating as a GitHub App. This includes the three major components, the App ID, the Install ID and the Private Key.\n\n```go\nfunc NewConfig(appID, installationID string, privateKey *rsa.PrivateKey, opts ...ConfigOption) *Config\n```\nNewConfig creates a new configuration object containing the three primary required configuration values. Options allow for the customization of rarely used configuration values. Options are evaluated in order from first to last.\n\n```go\ntype ConfigOption func(f *Config)\n```\nConfigOption is a function type that applies a mechanism to set optional configuration values.\n\n```go\nfunc WithAccessTokenURLPattern(pattern string) ConfigOption\n```\nWithAccessTokenURLPattern allows overriding of the GitHub api url that is used when generating installation access tokens. The default is the primary GitHub api url which should only be overridden for private GitHub installations.\n\nThe \\`pattern\\` parameter expects a single \\`%s\\` that represents the installation id that is provided with the rest of the configuration.\n\n```go\nfunc WithHTTPClient(client *http.Client) ConfigOption\n```\nWithHTTPClient is an option that allows a consumer to provider their own http client implementation.\n\n```go\nfunc WithJWTTokenCaching(beforeExp time.Duration) ConfigOption\n```\nWithJWTTokenCaching is an option that tells the GitHub app to cache its JWT App tokens. The amount of time that the tokens are cached is based on the provided \\`beforeExp\\` parameter + the configured token expiration. This results in a cache expiration of \\\u003ctoken expiration\u003e - \\\u003cbeforeExp\u003e.\n\n```go\nfunc WithJWTTokenExpiration(exp time.Duration) ConfigOption\n```\nWithJWTTokenExpiration is an option that allows overriding the default expiration date of the application JWTs.\n\n```go\ntype GitHubApp struct {\n\t// contains filtered or unexported fields\n}\n```\nGitHubApp is an object that can be used to generate application level JWTs or to request an OIDC token on behalf of an installation.\n\n```go\nfunc New(config *Config) *GitHubApp\n```\nNew creates a GitHubApp instance based on the provided GitHubAppConfig object.\n\n```go\nfunc (g *GitHubApp) AccessToken(ctx context.Context, request *TokenRequest) (string, error)\n```\nAccessToken calls the GitHub API to generate a new access token for this application installation with the requested permissions and repositories.\n\n```go\nfunc (g *GitHubApp) AccessTokenAllRepos(ctx context.Context, request *TokenRequestAllRepos) (string, error)\n```\nAccessTokenAllRepos calls the GitHub API to generate a new access token for this application installation with the requested permissions and all granted repositories.\n\n```go\nfunc (g *GitHubApp) AppToken() ([]byte, error)\n```\nAppToken creates a signed JWT to authenticate a GitHub app so that it can make API calls to GitHub.\n\n```go\nfunc (g *GitHubApp) Token() (*oauth2.Token, error)\n```\nToken adheres to the oauth2 TokenSource interface and returns a oauth2 token by creating a JWT token.\n\n```go\ntype TokenRequest struct {\n\tRepositories []string          `json:\"repositories\"`\n\tPermissions  map[string]string `json:\"permissions\"`\n}\n```\nTokenRequest is a struct that contains the list of repositories and the requested permissions / scopes that are requested when generating a new installation access token.\n\n```go\ntype TokenRequestAllRepos struct {\n\tPermissions map[string]string `json:\"permissions\"`\n}\n```\nTokenRequestAllRepos is a struct that contains the requested permissions/scopes that are requested when generating a new installation access token. This struct intentionally omits the repository properties to generate a token for all repositories granted to this GitHub app installation.\n\n","path":"github.com/abcxyz/pkg/githubapp","name":"githubapp","synopsis":"Package githubapp contains a class with methods for any service that needs to interact with GitHub as an app.","isRedistributable":true}
