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) |
InstallationAccessToken(java.lang.String installationAccessTokenUrl,
ApplicationKey applicationKey,
java.lang.String userAgent,
java.lang.String mediaType) |
InstallationAccessToken(java.lang.String installationAccessTokenUrl,
ApplicationKey applicationKey,
java.lang.String userAgent,
java.lang.String mediaType,
int cacheExpirationMinutes) |
| 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.
|
static InstallationAccessToken |
forRepository(java.lang.String repositoryUrl,
ApplicationKey applicationKey,
java.lang.String userAgent,
java.lang.String mediaType)
Creates an installation access token for the installation on a given repository.
|
java.lang.String |
get() |
static java.lang.String |
getInstallationUrl(java.lang.String repositoryUrl,
ApplicationKey applicationKey,
java.lang.String userAgent)
Looks up the location of the resource describing the installation for a given repository
|
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 InstallationAccessToken(java.lang.String installationAccessTokenUrl,
ApplicationKey applicationKey,
java.lang.String userAgent,
java.lang.String mediaType)
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 GitHubmediaType - The media type to request from the server via Accept headerpublic InstallationAccessToken(java.lang.String installationAccessTokenUrl,
ApplicationKey applicationKey,
java.lang.String userAgent,
java.lang.String mediaType,
int cacheExpirationMinutes)
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 GitHubmediaType - The media type to request from the server via Accept headercacheExpirationMinutes - Number of minutes to cache generated bearer tokens for authentication with GitHub, maximum 60public 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 periodpublic static InstallationAccessToken forRepository(java.lang.String repositoryUrl, ApplicationKey applicationKey, java.lang.String userAgent, java.lang.String mediaType)
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 GitHubmediaType - The media type to request from the server via Accept headerRequestLimitExceededException - If the request exceeded the maximum allowed requests to GitHub in a given time periodpublic static java.lang.String getInstallationUrl(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. It is recommended that clients use
forRepository(String, ApplicationKey, String) when possible - this call is primarily meant for cases
where the URL can be used with caching mechanisms to reduce the total number of calls to GitHub
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