Documentation
¶
Index ¶
- func App(ctx context.Context, appID string, installationID string, ...) (oauth2.TokenSource, error)
- func Basic(base http.RoundTripper, clientID string, clientSecret string) (*basicauth.Transport, error)
- func CLI(path string, host string) (*oauth2.Token, error)
- func Environment() (*oauth2.Token, error)
- func Host() string
- func Netrc(path string, host string) (*oauth2.Token, error)
- func Token(token string) *oauth2.Token
- func TokenSource(token *oauth2.Token) oauth2.TokenSource
- func TokenTransport(token *oauth2.Token) *oauth2.Transport
- func Transport(ctx context.Context, base http.RoundTripper) (http.RoundTripper, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func App ¶
func App( ctx context.Context, appID string, installationID string, privateKeyPath string, ) (oauth2.TokenSource, error)
App returns a oauth2.TokenSource for a given GitHub App installation. If appID is empty, it will look for the GH_APP_ID environment variable. If installationID is empty, it will look for the GH_APP_INSTALLATION_ID environment variable. If privateKeyPath is empty, it will look for the GH_APP_PRIVATE_KEY environment variable.
func Basic ¶
func Basic( base http.RoundTripper, clientID string, clientSecret string, ) (*basicauth.Transport, error)
Basic returns a basicauth.Transport using a Github OAuth App's client ID and client secret. If clientID is empty, it will look for the GH_CLIENT_ID environment variable. If clientSecret is empty, it will look for the GH_CLIENT_SECRET environment variable.
func CLI ¶
CLI retrieves an *oauth2.Token by running the 'gh auth token' command to fetch the token used by the GitHub CLI. If path is empty, it will try the GH_PATH environment variable, then to look for the 'gh' command in the system PATH. If host is empty, it will use the default GitHub host (github.com).
func Environment ¶
Environment reads a static GitHub token from the environment It tries (in order): GH_TOKEN, GITHUB_TOKEN, GH_ENTERPRISE_TOKEN, GITHUB_ENTERPRISE_TOKEN
func Host ¶
func Host() string
Host returns the host name of the GitHub server by reading the GH_HOST environment variable. If the variable is not set, it defaults to "github.com".
func Netrc ¶
Netrc attempts to extract a static API token from a .netrc file. If path is empty, ~/.netrc is used If host is empty, the default host is used
func Token ¶
Token creates a new oauth2.Token with the given token string. The token type is set to "Bearer" by default.
func TokenSource ¶
func TokenSource(token *oauth2.Token) oauth2.TokenSource
TokenSource creates a new oauth2.TokenSource using the provided token.
func TokenTransport ¶
TokenTransport creates a new oauth2.Transport using the provided token.
func Transport ¶
func Transport(ctx context.Context, base http.RoundTripper) (http.RoundTripper, error)
Transport returns an http.RoundTripper that adds GitHub authentication to each HTTP request. If base is nil, http.DefaultTransport is used. It will try (in order): Environment, App, OAuth, Netrc, CLI
Types ¶
This section is empty.