public class InstallationAccessToken
extends java.lang.Object
implements java.util.function.Supplier<java.lang.String>
Handles logic for exchanging an application key for an installation-specific access token and caching them until invalid, as described in authenticating as a GitHub App
Uses Java Supplier pattern to allow re-generation of tokens as needed
| Constructor and Description |
|---|
InstallationAccessToken(java.lang.String installationAccessTokenUrl,
ApplicationKey applicationKey,
java.lang.String userAgent) |
| Modifier and Type | Method and Description |
|---|---|
static InstallationAccessToken |
forRepository(java.lang.String repositoryUrl,
ApplicationKey applicationKey,
java.lang.String userAgent)
Creates an installation access token for the installation on a given repository.
|
java.lang.String |
get() |
public InstallationAccessToken(java.lang.String installationAccessTokenUrl,
ApplicationKey applicationKey,
java.lang.String userAgent)
installationAccessTokenUrl - URL which represents access token resources for a specific GitHub App installationapplicationKey - Key used to access GitHub web resources as a GitHub App outside an installation contextuserAgent - The user agent to make web requests as, as
required by GitHubpublic java.lang.String get()
get in interface java.util.function.Supplier<java.lang.String>KeyLoadingException - If the is an error making the GitHub web request to obtain the access tokenpublic static InstallationAccessToken forRepository(java.lang.String repositoryUrl, ApplicationKey applicationKey, java.lang.String userAgent)
Uses the provided applicationKey to read required installation details from GitHub specific to the
repository represented at the provided URL
repositoryUrl - The API URL which represents the target repository on GitHubapplicationKey - Application key which allows authentication as a GitHub App in web requestsuserAgent - User agent to make repository requests with, as
required by GitHubRequestLimitExceededException - If the request exceeded the maximum allowed requests to GitHub in a given time period