}
public FormValidation doCreateApiToken(@QueryParameter("username") final String username, @QueryParameter("password") final String password) {
try {
GitHub gh = GitHub.connectToEnterprise(this.serverAPIUrl, username, password);
GHAuthorization token = gh.createToken(Arrays.asList(GHAuthorization.REPO_STATUS, GHAuthorization.REPO), "Jenkins GitHub Pull Request Builder", null);
return FormValidation.ok("Access token created: " + token.getToken());
} catch (IOException ex) {
return FormValidation.error("GitHub API token couldn't be created: " + ex.getMessage());
}
}