GitHubAppClientFactory#

class safir.github.GitHubAppClientFactory(*, id, key, name, http_client)#

Bases: object

Factory for creating GitHub App clients authenticated either as an app or as an installation of that app.

Parameters:
  • id (str) – The GitHub App ID.

  • key (str) – The GitHub App private key.

  • name (str) – The GitHub App name. This identifies the app in the user agent string, and is typically the name of the GitHub repository the app is built from (e.g. lsst-sqre/times-square).

  • http_client (AsyncClient) – The httpx client.

Methods Summary

create_anonymous_client()

Create an anonymous client.

create_app_client()

Create a client authenticated as the GitHub App.

create_installation_client(installation_id)

Create a client authenticated as an installation of the GitHub App for a specific repository or organization.

create_installation_client_for_repo(owner, repo)

Create a client authenticated as an installation of the GitHub App for a specific repository or organization.

get_app_jwt()

Create the GitHub App's JWT based on application configuration.

Methods Documentation

create_anonymous_client()#

Create an anonymous client.

Returns:

The anonymous client.

Return type:

gidgethub.httpx.GitHubAPI

create_app_client()#

Create a client authenticated as the GitHub App.

Returns:

The app client.

Return type:

gidgethub.httpx.GitHubAPI

async create_installation_client(installation_id)#

Create a client authenticated as an installation of the GitHub App for a specific repository or organization.

Parameters:

installation_id (str) – The installation ID. This can be retrieved from the installation.id field of a webhook payload or from the id field of the GET "/repos/{owner}/{repo}/installation" GitHub endpoint.

Returns:

The installation client.

Return type:

gidgethub.httpx.GitHubAPI

async create_installation_client_for_repo(owner, repo)#

Create a client authenticated as an installation of the GitHub App for a specific repository or organization.

Parameters:
  • owner (str) – The owner of the repository.

  • repo (str) – The repository name.

Returns:

The installation client.

Return type:

gidgethub.httpx.GitHubAPI

get_app_jwt()#

Create the GitHub App’s JWT based on application configuration.

This token is for authenticating as the GitHub App itself, as opposed to an installation of the app.

Returns:

The JWT token.

Return type:

str