github

package
v0.0.0-...-8f8209c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	// contains filtered or unexported fields
}

func NewApp

func NewApp(appID int64, clientID, clientSecret, webhookSecret, callbackURL, privateKeyPath string) (*App, error)

NewApp creates a new GitHub App client. privateKeyPath is the path to the GitHub App's PEM private key file. If empty, the app will work for OAuth but installation token features will be unavailable.

func (*App) Branches

func (a *App) Branches(ctx context.Context, installationID int64, repository string) ([]string, error)

func (*App) Commit

func (a *App) Commit(ctx context.Context, installationID int64, repository, ref string) (Commit, error)

func (*App) ExchangeCode

func (a *App) ExchangeCode(ctx context.Context, code string) (*oauth2.Token, error)

ExchangeCode exchanges an authorization code for an OAuth2 token.

func (*App) FindInstallation

func (a *App) FindInstallation(ctx context.Context, repository string) (int64, error)

FindInstallation returns the installation ID of the GitHub App for the given repository. repository must be in "owner/repo" form. Uses app-level JWT auth (private key required).

func (*App) GetUser

func (a *App) GetUser(ctx context.Context, token *oauth2.Token) (*User, error)

GetUser fetches the authenticated user's profile from GitHub.

func (*App) Installation

func (a *App) Installation(ctx context.Context, installationID int64) (*Installation, error)

Installation fetches a single GitHub App installation by ID.

func (*App) InstallationID

func (a *App) InstallationID(ctx context.Context, userToken *oauth2.Token) (int64, error)

InstallationID discovers the GitHub App installation ID for the authenticated user. Uses the user's OAuth token to query their installations and returns the one matching this App's ID.

func (*App) InstallationToken

func (a *App) InstallationToken(ctx context.Context, installationID int64) (string, error)

func (*App) InstallationTokenForRepo

func (a *App) InstallationTokenForRepo(ctx context.Context, installationID int64, repository string) (string, error)

func (*App) Installations

func (a *App) Installations(ctx context.Context) ([]Installation, error)

Installations lists all installations of this GitHub App. Uses the App's private key to authenticate as the app itself (JWT).

func (*App) OAuthURL

func (a *App) OAuthURL(state string) string

OAuthURL returns the GitHub OAuth authorization URL with the given state parameter.

func (*App) RefreshToken

func (a *App) RefreshToken(ctx context.Context, token *oauth2.Token) (*oauth2.Token, error)

RefreshToken returns a fresh token, refreshing it if expired. GitHub App OAuth tokens have a configurable expiry. This uses the standard oauth2 token source to handle refresh transparently.

func (*App) UserInstallations

func (a *App) UserInstallations(ctx context.Context, userToken *oauth2.Token) ([]Installation, error)

UserInstallations returns all GitHub App installations accessible to the user. Uses the user's OAuth token to query their installations.

func (*App) WebhookSecret

func (a *App) WebhookSecret() string

type Commit

type Commit struct {
	SHA     string
	Message string
}

type Installation

type Installation struct {
	ID            int64
	AccountLogin  string
	AccountAvatar string
	AccountType   string // "Organization" or "User"
}

Installation represents a GitHub App installation on an account.

type User

type User struct {
	Login     string
	Name      string
	Email     string
	AvatarURL string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL