View Source GitHub.Apps (GitHub REST API Client v0.3.0)
Provides API endpoints related to apps
Link to this section Summary
Functions
Add a repository to an app installation
Check a token
Create a GitHub App from a manifest
Create an installation access token for an app
Delete an app authorization
Delete an installation for the authenticated app
Delete an app token
Get the authenticated app
Get an app
Get an installation for the authenticated app
Get an organization installation for the authenticated app
Get a repository installation for the authenticated app
Get a subscription plan for an account
Get a subscription plan for an account (stubbed)
Get a user installation for the authenticated app
Get a webhook configuration for an app
Get a delivery for an app webhook
List accounts for a plan
List accounts for a plan (stubbed)
List repositories accessible to the user access token
List installation requests for the authenticated app
List installations for the authenticated app
List app installations accessible to the user access token
List plans
List plans (stubbed)
List repositories accessible to the app installation
List subscriptions for the authenticated user
List subscriptions for the authenticated user (stubbed)
List deliveries for an app webhook
Redeliver a delivery for an app webhook
Remove a repository from an app installation
Reset a token
Revoke an installation access token
Create a scoped access token
Suspend an app installation
Unsuspend an app installation
Update a webhook configuration for an app
Link to this section Types
@type create_from_manifest_201_json_resp() :: %{ __info__: map(), client_id: String.t() | nil, client_secret: String.t() | nil, created_at: DateTime.t() | nil, description: String.t() | nil, events: [String.t()] | nil, external_url: String.t() | nil, html_url: String.t() | nil, id: integer() | nil, installations_count: integer() | nil, name: String.t() | nil, node_id: String.t() | nil, owner: GitHub.User.simple() | nil, pem: String.t() | nil, permissions: map() | nil, slug: String.t() | nil, updated_at: DateTime.t() | nil, webhook_secret: String.t() | nil }
@type list_installation_repos_for_authenticated_user_200_json_resp() :: %{ __info__: map(), repositories: [GitHub.Repository.t()], repository_selection: String.t() | nil, total_count: integer() }
@type list_installations_for_authenticated_user_200_json_resp() :: %{ __info__: map(), installations: [GitHub.Installation.t()], total_count: integer() }
@type list_repos_accessible_to_installation_200_json_resp() :: %{ __info__: map(), repositories: [GitHub.Repository.t()], repository_selection: String.t() | nil, total_count: integer() }
Link to this section Functions
add_repo_to_installation_for_authenticated_user(installation_id, repository_id, opts \\ [])
View Source@spec add_repo_to_installation_for_authenticated_user(integer(), integer(), keyword()) :: :ok | {:error, GitHub.Error.t()}
Add a repository to an app installation
Add a single repository to an installation. The authenticated user must have admin access to the repository.
resources
Resources
@spec check_token(String.t(), map(), keyword()) :: {:ok, GitHub.Authorization.t()} | {:error, GitHub.Error.t()}
Check a token
OAuth applications and GitHub applications with OAuth authorizations can use this API method for checking OAuth token validity without exceeding the normal rate limits for failed login attempts. Authentication works differently with this particular endpoint. You must use Basic Authentication to use this endpoint, where the username is the application client_id
and the password is its client_secret
. Invalid tokens will return 404 NOT FOUND
.
resources
Resources
@spec create_from_manifest( String.t(), keyword() ) :: {:ok, map()} | {:error, GitHub.Error.t()}
Create a GitHub App from a manifest
Use this endpoint to complete the handshake necessary when implementing the GitHub App Manifest flow. When you create a GitHub App with the manifest flow, you receive a temporary code
used to retrieve the GitHub App's id
, pem
(private key), and webhook_secret
.
resources
Resources
create_installation_access_token(installation_id, body, opts \\ [])
View Source@spec create_installation_access_token(integer(), map(), keyword()) :: {:ok, GitHub.Installation.Token.t()} | {:error, GitHub.Error.t()}
Create an installation access token for an app
Creates an installation access token that enables a GitHub App to make authenticated API requests for the app's installation on an organization or individual account. Installation tokens expire one hour from the time you create them. Using an expired token produces a status code of 401 - Unauthorized
, and requires creating a new installation token. By default the installation token has access to all repositories that the installation can access.
Optionally, you can use the repositories
or repository_ids
body parameters to specify individual repositories that the installation access token can access. If you don't use repositories
or repository_ids
to grant access to specific repositories, the installation access token will have access to all repositories that the installation was granted access to. The installation access token cannot be granted access to repositories that the installation was not granted access to. Up to 500 repositories can be listed in this manner.
Optionally, use the permissions
body parameter to specify the permissions that the installation access token should have. If permissions
is not specified, the installation access token will have all of the permissions that were granted to the app. The installation access token cannot be granted permissions that the app was not granted.
When using the repository or permission parameters to reduce the access of the token, the complexity of the token is increased due to both the number of permissions in the request and the number of repositories the token will have access to. If the complexity is too large, the token will fail to be issued. If this occurs, the error message will indicate the maximum number of repositories that should be requested. For the average application requesting 8 permissions, this limit is around 5000 repositories. With fewer permissions requested, more repositories are supported.
You must use a JWT to access this endpoint.
resources
Resources
@spec delete_authorization(String.t(), map(), keyword()) :: :ok | {:error, GitHub.Error.t()}
Delete an app authorization
OAuth and GitHub application owners can revoke a grant for their application and a specific user. You must use Basic Authentication when accessing this endpoint, using the OAuth application's client_id
and client_secret
as the username and password. You must also provide a valid OAuth access_token
as an input parameter and the grant for the token's owner will be deleted.
Deleting an application's grant will also delete all OAuth tokens associated with the application for the user. Once deleted, the application will have no access to the user's account and will no longer be listed on the application authorizations settings screen within GitHub.
resources
Resources
@spec delete_installation( integer(), keyword() ) :: :ok | {:error, GitHub.Error.t()}
Delete an installation for the authenticated app
Uninstalls a GitHub App on a user, organization, or business account. If you prefer to temporarily suspend an app's access to your account's resources, then we recommend the "Suspend an app installation" endpoint.
You must use a JWT to access this endpoint.
resources
Resources
@spec delete_token(String.t(), map(), keyword()) :: :ok | {:error, GitHub.Error.t()}
Delete an app token
OAuth or GitHub application owners can revoke a single token for an OAuth application or a GitHub application with an OAuth authorization. You must use Basic Authentication when accessing this endpoint, using the application's client_id
and client_secret
as the username and password.
resources
Resources
@spec get_authenticated(keyword()) :: {:ok, GitHub.App.t()} | {:error, GitHub.Error.t()}
Get the authenticated app
Returns the GitHub App associated with the authentication credentials used. To see how many app installations are associated with this GitHub App, see the installations_count
in the response. For more details about your app's installations, see the "List installations for the authenticated app" endpoint.
You must use a JWT to access this endpoint.
resources
Resources
@spec get_by_slug( String.t(), keyword() ) :: {:ok, GitHub.App.t()} | {:error, GitHub.Error.t()}
Get an app
Note: The :app_slug
is just the URL-friendly name of your GitHub App. You can find this on the settings page for your GitHub App (e.g., https://github.com/settings/apps/:app_slug
).
resources
Resources
@spec get_installation( integer(), keyword() ) :: {:ok, GitHub.Installation.t()} | {:error, GitHub.Error.t()}
Get an installation for the authenticated app
Enables an authenticated GitHub App to find an installation's information using the installation id.
You must use a JWT to access this endpoint.
resources
Resources
@spec get_org_installation( String.t(), keyword() ) :: {:ok, GitHub.Installation.t()} | {:error, GitHub.Error.t()}
Get an organization installation for the authenticated app
Enables an authenticated GitHub App to find the organization's installation information.
You must use a JWT to access this endpoint.
resources
Resources
@spec get_repo_installation(String.t(), String.t(), keyword()) :: {:ok, GitHub.Installation.t()} | {:error, GitHub.Error.t()}
Get a repository installation for the authenticated app
Enables an authenticated GitHub App to find the repository's installation information. The installation's account type will be either an organization or a user account, depending which account the repository belongs to.
You must use a JWT to access this endpoint.
resources
Resources
@spec get_subscription_plan_for_account( integer(), keyword() ) :: {:ok, GitHub.Marketplace.Purchase.t()} | {:error, GitHub.Error.t()}
Get a subscription plan for an account
Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
resources
Resources
@spec get_subscription_plan_for_account_stubbed( integer(), keyword() ) :: {:ok, GitHub.Marketplace.Purchase.t()} | {:error, GitHub.Error.t()}
Get a subscription plan for an account (stubbed)
Shows whether the user or organization account actively subscribes to a plan listed by the authenticated GitHub App. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
resources
Resources
@spec get_user_installation( String.t(), keyword() ) :: {:ok, GitHub.Installation.t()} | {:error, GitHub.Error.t()}
Get a user installation for the authenticated app
Enables an authenticated GitHub App to find the user’s installation information.
You must use a JWT to access this endpoint.
resources
Resources
@spec get_webhook_config_for_app(keyword()) :: {:ok, GitHub.Webhook.Config.t()} | {:error, GitHub.Error.t()}
Get a webhook configuration for an app
Returns the webhook configuration for a GitHub App. For more information about configuring a webhook for your app, see "Creating a GitHub App."
You must use a JWT to access this endpoint.
resources
Resources
@spec get_webhook_delivery( integer(), keyword() ) :: {:ok, GitHub.Hook.Delivery.t()} | {:error, GitHub.Error.t()}
Get a delivery for an app webhook
Returns a delivery for the webhook configured for a GitHub App.
You must use a JWT to access this endpoint.
resources
Resources
@spec list_accounts_for_plan( integer(), keyword() ) :: {:ok, [GitHub.Marketplace.Purchase.t()]} | {:error, GitHub.Error.t()}
List accounts for a plan
Returns user and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
options
Options
sort
: The property to sort the results by.direction
: To return the oldest accounts first, set toasc
. Ignored without thesort
parameter.per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_accounts_for_plan_stubbed( integer(), keyword() ) :: {:ok, [GitHub.Marketplace.Purchase.t()]} | {:error, GitHub.Error.t()}
List accounts for a plan (stubbed)
Returns repository and organization accounts associated with the specified plan, including free plans. For per-seat pricing, you see the list of accounts that have purchased the plan, including the number of seats purchased. When someone submits a plan change that won't be processed until the end of their billing cycle, you will also see the upcoming pending change.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
options
Options
sort
: The property to sort the results by.direction
: To return the oldest accounts first, set toasc
. Ignored without thesort
parameter.per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
list_installation_repos_for_authenticated_user(installation_id, opts \\ [])
View Source@spec list_installation_repos_for_authenticated_user( integer(), keyword() ) :: {:ok, map()} | {:error, GitHub.Error.t()}
List repositories accessible to the user access token
List repositories that the authenticated user has explicit permission (:read
, :write
, or :admin
) to access for an installation.
The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
The access the user has to each repository is included in the hash under the permissions
key.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_installation_requests_for_authenticated_app(keyword()) :: {:ok, [GitHub.App.InstallationRequest.t()]} | {:error, GitHub.Error.t()}
List installation requests for the authenticated app
Lists all the pending installation requests for the authenticated GitHub App.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_installations(keyword()) :: {:ok, [GitHub.Installation.t()]} | {:error, GitHub.Error.t()}
List installations for the authenticated app
The permissions the installation has are included under the permissions
key.
You must use a JWT to access this endpoint.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."since
: Only show results that were last updated after the given time. This is a timestamp in ISO 8601 format:YYYY-MM-DDTHH:MM:SSZ
.outdated
resources
Resources
@spec list_installations_for_authenticated_user(keyword()) :: {:ok, map()} | {:error, GitHub.Error.t()}
List app installations accessible to the user access token
Lists installations of your GitHub App that the authenticated user has explicit permission (:read
, :write
, or :admin
) to access.
The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
You can find the permissions for the installation under the permissions
key.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_plans(keyword()) :: {:ok, [GitHub.Marketplace.ListingPlan.t()]} | {:error, GitHub.Error.t()}
List plans
Lists all plans that are part of your GitHub Marketplace listing.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_plans_stubbed(keyword()) :: {:ok, [GitHub.Marketplace.ListingPlan.t()]} | {:error, GitHub.Error.t()}
List plans (stubbed)
Lists all plans that are part of your GitHub Marketplace listing.
GitHub Apps must use a JWT to access this endpoint. OAuth apps must use basic authentication with their client ID and client secret to access this endpoint.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_repos_accessible_to_installation(keyword()) :: {:ok, map()} | {:error, GitHub.Error.t()}
List repositories accessible to the app installation
List repositories that an app installation can access.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_subscriptions_for_authenticated_user(keyword()) :: {:ok, [GitHub.User.MarketplacePurchase.t()]} | {:error, GitHub.Error.t()}
List subscriptions for the authenticated user
Lists the active subscriptions for the authenticated user.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_subscriptions_for_authenticated_user_stubbed(keyword()) :: {:ok, [GitHub.User.MarketplacePurchase.t()]} | {:error, GitHub.Error.t()}
List subscriptions for the authenticated user (stubbed)
Lists the active subscriptions for the authenticated user.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."page
: The page number of the results to fetch. For more information, see "Using pagination in the REST API."
resources
Resources
@spec list_webhook_deliveries(keyword()) :: {:ok, [GitHub.Hook.DeliveryItem.t()]} | {:error, GitHub.Error.t()}
List deliveries for an app webhook
Returns a list of webhook deliveries for the webhook configured for a GitHub App.
You must use a JWT to access this endpoint.
options
Options
per_page
: The number of results per page (max 100). For more information, see "Using pagination in the REST API."cursor
: Used for pagination: the starting delivery from which the page of deliveries is fetched. Refer to thelink
header for the next and previous page cursors.redelivery
resources
Resources
@spec redeliver_webhook_delivery( integer(), keyword() ) :: {:ok, GitHub.Accepted.json_resp()} | {:error, GitHub.Error.t()}
Redeliver a delivery for an app webhook
Redeliver a delivery for the webhook configured for a GitHub App.
You must use a JWT to access this endpoint.
resources
Resources
remove_repo_from_installation_for_authenticated_user(installation_id, repository_id, opts \\ [])
View Source@spec remove_repo_from_installation_for_authenticated_user( integer(), integer(), keyword() ) :: :ok | {:error, GitHub.Error.t()}
Remove a repository from an app installation
Remove a single repository from an installation. The authenticated user must have admin access to the repository. The installation must have the repository_selection
of selected
.
resources
Resources
@spec reset_token(String.t(), map(), keyword()) :: {:ok, GitHub.Authorization.t()} | {:error, GitHub.Error.t()}
Reset a token
OAuth applications and GitHub applications with OAuth authorizations can use this API method to reset a valid OAuth token without end-user involvement. Applications must save the "token" property in the response because changes take effect immediately. You must use Basic Authentication when accessing this endpoint, using the application's client_id
and client_secret
as the username and password. Invalid tokens will return 404 NOT FOUND
.
resources
Resources
@spec revoke_installation_access_token(keyword()) :: :ok | {:error, GitHub.Error.t()}
Revoke an installation access token
Revokes the installation token you're using to authenticate as an installation and access this endpoint.
Once an installation token is revoked, the token is invalidated and cannot be used. Other endpoints that require the revoked installation token must have a new installation token to work. You can create a new token using the "Create an installation access token for an app" endpoint.
resources
Resources
@spec scope_token(String.t(), map(), keyword()) :: {:ok, GitHub.Authorization.t()} | {:error, GitHub.Error.t()}
Create a scoped access token
Use a non-scoped user access token to create a repository-scoped and/or permission-scoped user access token. You can specify which repositories the token can access and which permissions are granted to the token.
Invalid tokens will return 404 NOT FOUND
.
You must use Basic Authentication
when accessing this endpoint, using the client_id
and client_secret
of the GitHub App
as the username and password.
resources
Resources
@spec suspend_installation( integer(), keyword() ) :: :ok | {:error, GitHub.Error.t()}
Suspend an app installation
Suspends a GitHub App on a user, organization, or business account, which blocks the app from accessing the account's resources. When a GitHub App is suspended, the app's access to the GitHub API or webhook events is blocked for that account.
You must use a JWT to access this endpoint.
resources
Resources
@spec unsuspend_installation( integer(), keyword() ) :: :ok | {:error, GitHub.Error.t()}
Unsuspend an app installation
Removes a GitHub App installation suspension.
You must use a JWT to access this endpoint.
resources
Resources
@spec update_webhook_config_for_app( map(), keyword() ) :: {:ok, GitHub.Webhook.Config.t()} | {:error, GitHub.Error.t()}
Update a webhook configuration for an app
Updates the webhook configuration for a GitHub App. For more information about configuring a webhook for your app, see "Creating a GitHub App."
You must use a JWT to access this endpoint.