當前位置: 首頁>>代碼示例>>Java>>正文


Java GitHub.connectUsingOAuth方法代碼示例

本文整理匯總了Java中org.kohsuke.github.GitHub.connectUsingOAuth方法的典型用法代碼示例。如果您正苦於以下問題:Java GitHub.connectUsingOAuth方法的具體用法?Java GitHub.connectUsingOAuth怎麽用?Java GitHub.connectUsingOAuth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.kohsuke.github.GitHub的用法示例。


在下文中一共展示了GitHub.connectUsingOAuth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub getGitHub() throws IOException {
    final SettingsRepository settingsRepository = ServiceRegistry.getSettingsRepository();
    final String apiUrl = settingsRepository.getGitHubApiUrl();
    final String personalAccessToken = settingsRepository.getPersonalAccessToken();

    if (apiUrl != null) {
        if (personalAccessToken != null) {
            return GitHub.connectToEnterprise(apiUrl, personalAccessToken);
        } else {
            return GitHub.connectToEnterpriseAnonymously(apiUrl);
        }
    } else {
        if (personalAccessToken != null) {
            return GitHub.connectUsingOAuth(personalAccessToken);
        } else {
            return GitHub.connectAnonymously();
        }
    }
}
 
開發者ID:terma,項目名稱:github-pr-coverage-status,代碼行數:20,代碼來源:CachedGitHubRepository.java

示例2: createGitHubClient

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
GitHub createGitHubClient(String usernameToUse, String passwordToUse, String oauthAccessTokenToUse, String endPointToUse) throws Exception {
    GitHub github = null;
    if (usernameAndPasswordIsAvailable(usernameToUse, passwordToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectToEnterprise(endPointToUse, usernameToUse, passwordToUse);
        } else {
            github = GitHub.connectUsingPassword(usernameToUse, passwordToUse);
        }
    }
    if (oAuthTokenIsAvailable(oauthAccessTokenToUse)) {
        if (endPointIsAvailable(endPointToUse)) {
            github = GitHub.connectUsingOAuth(endPointToUse, oauthAccessTokenToUse);
        } else {
            github = GitHub.connectUsingOAuth(oauthAccessTokenToUse);
        }
    }
    if (github == null) {
        github = GitHub.connect();
    }
    return github;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-build-status-notifier,代碼行數:22,代碼來源:GitHubProvider.java

示例3: run

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
public void run(UpsourceConfiguration configuration, Environment environment) throws Exception {
  DBIFactory factory = new DBIFactory();
  DBI jdbi = factory.build(environment, configuration.getDataSourceFactory(), "data-source");
  GitHub gitHub = GitHub.connectUsingOAuth(configuration.getGitHubOAuthToken());
  ImmutableMap.Builder<String, Repository> repositoryBuilder = ImmutableMap.builder();
  ImmutableMap.Builder<String, ExecutorService> executorBuilder = ImmutableMap.builder();
  configuration.getRepositories().forEach(
      repository -> {
        repositoryBuilder.put(repository.getFullName(), repository);
        executorBuilder.put(repository.getFullName(), Executors.newSingleThreadExecutor());
      });
  List<String> repoNames = configuration.getRepositories().stream().map(Repository::getFullName).
      collect(Collectors.toList());
  GitHubConnector gitHubConnector =
      new GitHubConnector(gitHub, repositoryBuilder.build(), executorBuilder.build());
  gitHubConnector.handleStartup();
  GitHubWebhookResource gitHubWebhookResource =
      new GitHubWebhookResource(gitHubConnector, ImmutableList.copyOf(repoNames));
  environment.jersey().register(
      gitHubWebhookResource);
  environment.jersey().register(new GitHubHMACFilter(configuration.getGitHubWebhookSecret()));
  //environment.jersey().register(new UserResource(jdbi.onDemand(UserDao.class)));
  environment.jersey().register(DeclarativeLinkingFeature.class);
}
 
開發者ID:tox4j,項目名稱:upsource-bot,代碼行數:26,代碼來源:UpsourceApplication.java

示例4: fetch

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private PullRequest fetch(PullRequestKey key) {
    try {
        GitHub github;
        if(currentUser== null) {
            github = GitHub.connectAnonymously();
        } else {
            github = GitHub.connectUsingOAuth(currentUser.getAccessToken());
        }
        return GithubUtil.toPullRequest(
                    github.getUser(key.getUser())
                        .getRepository(key.getRepository())
                        .getPullRequest(key.getNumber()));

    } catch (Exception e) {
        notification.sendMessage(key, "Could not fetch pull request data from GitHub: " + e.getMessage());
        throw new RuntimeException("Could not fetch PullRequest from GitHub for " + key, e);
    }
}
 
開發者ID:aslakknutsen,項目名稱:github-merge,代碼行數:19,代碼來源:PullRequestService.java

示例5: createGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub createGitHub(String accessToken, GitHubConfiguration gitHubConfiguration) throws IOException {
    if (gitHubConfiguration.authenticateWith() == AuthenticateWith.GITHUB_ENTERPRISE) {
        LOG.debug("Create GitHub connection to enterprise GitHub with token");
        return GitHub.connectToEnterprise(gitHubConfiguration.gitHubEnterpriseUrl(), accessToken);
    } else {
        LOG.debug("Create GitHub connection to public GitHub with token");
        return GitHub.connectUsingOAuth(accessToken);
    }
}
 
開發者ID:gocd-contrib,項目名稱:github-oauth-authorization-plugin,代碼行數:10,代碼來源:GitHubClientBuilder.java

示例6: setOauthToken

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
public static void setOauthToken(String oauthToken) {
  validateOauthToken(oauthToken);

  try {
    gitHub = GitHub.connectUsingOAuth(oauthToken);
  } catch (IOException e) {
    Log.e("Error connecting to the GitHub API using the oauth token " + oauthToken);
  }
}
 
開發者ID:Karumi,項目名稱:Reddo,代碼行數:10,代碼來源:GitHubApiClient.java

示例7: connectToPublicGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private GitHub connectToPublicGitHub(GithubPluginSettings pluginSettings) throws IOException {
    if (pluginSettings.containsUsernameAndPassword()) {
        LOGGER.debug("Create GitHub connection to public GitHub using username and password");
        return GitHub.connectUsingPassword(pluginSettings.getUsername(), pluginSettings.getPassword());
    } else if (pluginSettings.containsOAuthToken()) {
        LOGGER.debug("Create GitHub connection to public GitHub with token");
        return GitHub.connectUsingOAuth(pluginSettings.getOauthToken());
    }
    return null;
}
 
開發者ID:gocd-contrib,項目名稱:gocd-oauth-login,代碼行數:11,代碼來源:GitHubProvider.java

示例8: oauthConnect

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * Connect to GitHub API using OAuth
 *
 * @param oauthToken token for OAuth connection
 * @return connected GitHub API class
 */
public GitHub oauthConnect(String oauthToken) throws ServerException, UnauthorizedException {
  try {
    return GitHub.connectUsingOAuth(oauthToken);
  } catch (IOException e) {
    throw new ServerException(e.getMessage());
  }
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:14,代碼來源:GitHubFactory.java

示例9: runNotesBuilder

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
/**
 * Executes NotesBuilder based on passed command line options.
 * @param cliOptions command line options.
 * @return result of NotesBuilder work.
 * @throws IOException if an I/O error occurs.
 * @throws GitAPIException if an error occurs while accessing GitHub API.
 */
private static Result runNotesBuilder(CliOptions cliOptions)
        throws IOException, GitAPIException {

    final String localRepoPath = cliOptions.getLocalRepoPath();
    final String startRef = cliOptions.getStartRef();
    final String endRef = cliOptions.getEndRef();
    final String authToken = cliOptions.getAuthToken();

    final GitHub connection;
    if (authToken == null) {
        connection = GitHub.connectAnonymously();
    }
    else {
        connection = GitHub.connectUsingOAuth(authToken);
    }

    final GHRepository remoteRepo = connection.getRepository(REMOTE_REPO_PATH);
    final Result result = NotesBuilder.buildResult(remoteRepo, localRepoPath, startRef, endRef);
    if (result.hasWarnings()) {
        printListOf(result.getWarningMessages());
    }
    if (result.hasErrors()) {
        printListOf(result.getErrorMessages());
    }
    return result;
}
 
開發者ID:checkstyle,項目名稱:contribution,代碼行數:34,代碼來源:Main.java

示例10: getUserInfo

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
public OAuthUserInfo getUserInfo(OAuthToken token) throws IOException {
  String oauthToken = token.getToken();
  GitHub hub = GitHub.connectUsingOAuth(oauthToken);
  GHMyself myself = hub.getMyself();
  String login = myself.getLogin();
  return new OAuthUserInfo(
      ExternalId.SCHEME_GERRIT + login, login, myself.getEmail(), myself.getName(), null);
}
 
開發者ID:GerritCodeReview,項目名稱:plugins_github,代碼行數:10,代碼來源:GitHubOAuthServiceProvider.java

示例11: connect

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private void connect() throws IOException{
	String accessToken = GhprbTrigger.getDscp().getAccessToken();
	String serverAPIUrl = GhprbTrigger.getDscp().getServerAPIUrl();
	if(accessToken != null && !accessToken.isEmpty()) {
		try {
			gh = GitHub.connectUsingOAuth(serverAPIUrl, accessToken);
		} catch(IOException e) {
			logger.log(Level.SEVERE, "Can''t connect to {0} using oauth", serverAPIUrl);
			throw e;
		}
	} else {
		gh = GitHub.connect(GhprbTrigger.getDscp().getUsername(), null, GhprbTrigger.getDscp().getPassword());
	}
}
 
開發者ID:ds2wang,項目名稱:ghprb-copy,代碼行數:15,代碼來源:GhprbGitHub.java

示例12: getGithub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
private static GitHub getGithub(final String token) {
    try {
        return GitHub.connectUsingOAuth(SetupConfig.get().getGithubApiUrl(), token);
    } catch (final IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:groupon,項目名稱:DotCi,代碼行數:8,代碼來源:GithubRepositoryService.java

示例13: onEnable

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
public void onEnable() {
    saveDefaultConfig();
    ConfigurationSerialization.registerClass(KitImpl.class);
    getServer().getScheduler().scheduleSyncRepeatingTask(this, new TimeSlowRunnable(this), 100L, 100L);
    registerListeners(new PlayerJoinListener(this), new PlayerQuitListener(this), new PlayerTeleportListener(this),
            new PlayerItemConsumeListener(this),
            new WarpSignChangeListener(this), new WarpPlayerInteractListener(this));
    registerCommands();
    warpManager = new WarpManager(this);
    kitManager = new KitManager(this);
    drinkManager = new DrinkManager(this);
    try {
        File gitHubFile = new File(getDataFolder(), "github.yml");
        if (gitHubFile.exists()) {
            YamlConfiguration gitHubConfig = new YamlConfiguration();
            gitHubConfig.load(gitHubFile);
            if (gitHubConfig.getString("oauth") != null) {
                getLogger().info("Found OAuth token in GitHub config, attempting to connect using OAuth...");
                gitHub = GitHub.connectUsingOAuth(gitHubConfig.getString("oauth"));
            } else if (gitHubConfig.getString("user") != null && gitHubConfig.getString("password") != null) {
                getLogger().info("Found user and password in GitHub config, attempting to connect using user and password...");
                gitHub = GitHub.connectUsingPassword(gitHubConfig.getString("user"), gitHubConfig.getString("password"));
            } else {
                getLogger().info("No user & password or OAuth token found in GitHub config, attempting to connect anonymously...");
                gitHub = GitHub.connectAnonymously();
            }
        } else {
            getLogger().info("No GitHub config found, attempting to connect anonymously...");
            gitHub = GitHub.connectAnonymously();
        }
    } catch (IOException | InvalidConfigurationException exception) {
        exception.printStackTrace();
    }
    drinkManager.setupRecipes();
    logMessagesEnabledFile = new File(getDataFolder(), "log-messages-enabled.yml");
}
 
開發者ID:WaywardRealms,項目名稱:Wayward,代碼行數:38,代碼來源:WaywardEssentials.java

示例14: connect

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
@Override
protected void connect() {
	try {
		gh = GitHub.connectUsingOAuth(getUserToken().getToken());
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:ahn,項目名稱:mideaas,代碼行數:9,代碼來源:GitHubService.java

示例15: getGitHub

import org.kohsuke.github.GitHub; //導入方法依賴的package包/類
protected GitHub getGitHub(StaplerRequest request) throws IOException {
    return GitHub.connectUsingOAuth(getSetupConfig().getGithubApiUrl(), getAccessToken(request));
}
 
開發者ID:groupon,項目名稱:DotCi,代碼行數:4,代碼來源:GithubRepoAction.java


注:本文中的org.kohsuke.github.GitHub.connectUsingOAuth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。