当前位置: 首页>>代码示例>>Java>>正文


Java GitHubClient.setOAuth2Token方法代码示例

本文整理汇总了Java中org.eclipse.egit.github.core.client.GitHubClient.setOAuth2Token方法的典型用法代码示例。如果您正苦于以下问题:Java GitHubClient.setOAuth2Token方法的具体用法?Java GitHubClient.setOAuth2Token怎么用?Java GitHubClient.setOAuth2Token使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.egit.github.core.client.GitHubClient的用法示例。


在下文中一共展示了GitHubClient.setOAuth2Token方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
public GitHubGovernorClient build(
        GitHubGovernorConfiguration governorConfiguration) throws Exception {
    Validate.notNull(governorConfiguration, "GitHub governor configuration has to be set.");
    this.gitHubGovernorConfiguration = governorConfiguration;

    final GitHubClient gitHubClient = new GitHubClient();
    if (this.gitHubGovernorConfiguration.getUsername() != null && this.gitHubGovernorConfiguration.getUsername().length() > 0 && this.gitHubGovernorConfiguration.getPassword() != null && this.gitHubGovernorConfiguration.getPassword().length() > 0) {
        gitHubClient.setCredentials(this.gitHubGovernorConfiguration.getUsername(), this.gitHubGovernorConfiguration.getPassword());
    }

    if (this.gitHubGovernorConfiguration.getToken() != null && this.gitHubGovernorConfiguration.getToken().length() > 0) {
        gitHubClient.setOAuth2Token(gitHubGovernorConfiguration.getToken());
    }

    final GitHubGovernorClient gitHubGovernorClient = new GitHubGovernorClient(gitHubClient, gitHubGovernorConfiguration);
    gitHubGovernorClient.setGovernorStrategy(new GitHubGovernorStrategy(this.gitHubGovernorConfiguration));

    return gitHubGovernorClient;
}
 
开发者ID:arquillian,项目名称:arquillian-governor,代码行数:21,代码来源:GitHubGovernorClientFactory.java

示例2: createGitHubClient

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
protected GitHubClient createGitHubClient() {
    // GitHub client (non authentified)
    GitHubClient client = new GitHubClient() {
        @Override
        protected HttpURLConnection configureRequest(HttpURLConnection request) {
            HttpURLConnection connection = super.configureRequest(request);
            connection.setRequestProperty(HEADER_ACCEPT, "application/vnd.github.v3.full+json");
            return connection;
        }
    };
    // Authentication
    String oAuth2Token = configuration.getOauth2Token();
    if (StringUtils.isNotBlank(oAuth2Token)) {
        client.setOAuth2Token(oAuth2Token);
    } else {
        String user = configuration.getUser();
        String password = configuration.getPassword();
        if (StringUtils.isNotBlank(user)) {
            client.setCredentials(user, password);
        }
    }
    return client;
}
 
开发者ID:nemerosa,项目名称:ontrack,代码行数:24,代码来源:DefaultOntrackGitHubClient.java

示例3: GFMMassConverter

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
public GFMMassConverter() throws IOException {

		gFMMassConverterConfiguration = new GFMMassConverterConfiguration();

		//GitHub client with optional authentication token
		gitHubClient = new GitHubClient();
		final String authenticationToken = gFMMassConverterConfiguration.getGFMAuthenticationToken();
		if( null != authenticationToken && ! authenticationToken.isEmpty() ) {
			gitHubClient.setOAuth2Token( authenticationToken );
		}

		final String gitHubUser = gFMMassConverterConfiguration.getGFMGitHubUser();
		final String gitHubProjet = gFMMassConverterConfiguration.getGFMGitHubRepository();

		//Get the optional repository configured
		if( null != gitHubUser && ! gitHubUser.isEmpty() && null != gitHubProjet && ! gitHubProjet.isEmpty() ) {

			final RepositoryService repositoryService = new RepositoryService( gitHubClient );
			gitHubProjectRepository = repositoryService.getRepository( gitHubUser, gitHubProjet );
		}
		else {
			gitHubProjectRepository = null;
		}

		markdownService = new MarkdownService( gitHubClient );
	}
 
开发者ID:Sylvain-Bugat,项目名称:github-flavored-markdown-converter,代码行数:27,代码来源:GFMMassConverter.java

示例4: doDelete

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	// handle the DELETE request
    GitHubClient client = new GitHubClient();
	client.setOAuth2Token(req.getParameter("access_token"));
	String repoOwner = req.getParameter("writer");
	String reviewer = req.getParameter("reviewer");
	String repoName = req.getParameter("repo");
	
	Repo repo = new Repo(repoOwner, repoName);
	
	String closeComment = "@" + reviewer + " is no longer reviewing this paper.";
	ReviewSubmitServlet.closeReviewIssue(client, repo, reviewer, closeComment);
	
	DBAbstraction database = DatabaseFactory.getDatabase();
	database.removeReviewFromDatastore(reviewer, repo);
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:18,代码来源:ReviewRequestServlet.java

示例5: doGet

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	GitHubClient client = new GitHubClient();
	client.setOAuth2Token(req.getParameter("access_token"));
	UserService userService = new UserService(client);
	
	String login = req.getParameter("user");
	
	User user = userService.getUser(login);
	
	JSONObject userJ = new JSONObject();

	try {
		userJ.put("login", user.getLogin());
		userJ.put("email", user.getEmail());
		userJ.put("name", user.getName());
		
		resp.setContentType("application/json");
		resp.getWriter().write(userJ.toString());
	} catch(JSONException e) {
		e.printStackTrace();
	}
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:24,代码来源:UserServlet.java

示例6: doGet

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	GitHubClient client = new GitHubClient();
	client.setOAuth2Token(req.getParameter("access_token"));
	
	UserService userService = new UserService(client);
	User user = userService.getUser();
	OrganizationService orgService = new OrganizationService(client);
	List<User> users = orgService.getOrganizations(user.getLogin());
	
	JSONArray logins = new JSONArray();
	logins.put(user.getLogin());
	for(User u : users) {
		logins.put(u.getLogin());
	}
	
	resp.setContentType("application/json");
	resp.getWriter().write(logins.toString());
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:20,代码来源:RepoSourceServlet.java

示例7: run

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
public void run() {
		try {
			GitHubClient client = new GitHubClient();
			client.setOAuth2Token(accessToken);
			
			DBAbstraction database = DatabaseFactory.getDatabase();
			UserService userService = new UserService(client);
			User reviewer = userService.getUser();
			List<Label> customLabels = createCustomLabels(client);
			
			createIssues(client, customLabels);
			
			String closeComment = "@" + reviewer.getLogin() + " has reviewed this paper.";
			
                  closeReviewIssue(client, repo, reviewer.getLogin(), closeComment);
			
			database.removeReviewFromDatastore(reviewer.getLogin(), repo);
			
		} catch(IOException e) {
		    e.printStackTrace();
			System.err.println("Error processing Pdf.");
		}
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:25,代码来源:ReviewSubmitServlet.java

示例8: getCommitsFromGitHub

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
/**
 * Fetches list of commits form GitHub repository.
 *
 * @param auth
 * @param owner
 * @param name
 * @param branch
 * @return list of commits
 * @throws IOException
 */
private List<RepositoryCommit> getCommitsFromGitHub(final String auth, final String owner, final String name,
													final String branch) throws IOException {
	GitHubClient client = new GitHubClient();

	if (auth != null && !auth.isEmpty()) {
		client.setOAuth2Token(auth);
	} else {
		log.warn("OAuth2Token not set");
	}

	CommitService cs = new CommitService(client);

	RepositoryService rs = new RepositoryService(client);
	final Repository repository = rs.getRepository(owner, name);

	return cs.getCommits(repository, branch, null);

}
 
开发者ID:ever-been,项目名称:benchmark-hazelcast3,代码行数:29,代码来源:HazelcastBenchmark.java

示例9: IssueToEGitHub

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
/**
 * Class to convert the issue and transfers it
 * 
 * @param data
 * @throws IOException
 */
public IssueToEGitHub( final ConnectionData data )
        throws IOException {

    this.repositoryParam = data.getRepository();
    this.userParam = data.getUser();
    this.mantisbturlParam = data.getMantisurl();

    GitHubClient client = new GitHubClient();
    client.setOAuth2Token( data.getToken() );

    RepositoryService repositoryService = new RepositoryService( client );
    MilestoneService milestoneService = new MilestoneService( client );
    IssueService issueService = new IssueService( client );

    Repository repository = repositoryService.getRepository( this.userParam, this.repositoryParam );

    TransferService transferService = new TransferService( milestoneMap, issueService, milestoneService, userParam,
            repositoryParam, repository );

    this.transferService = transferService;

    readMilestones( milestoneService );
}
 
开发者ID:tpummer,项目名称:issue2github,代码行数:30,代码来源:IssueToEGitHub.java

示例10: IssueEventCollector

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
public IssueEventCollector(String repoOwner, String repoName, String token) throws IssueEventException {
    gitHubClient = new GitHubClient();
    if (token != null) {
        gitHubClient.setOAuth2Token(token);
    }

    try {
        service = new RepositoryService(gitHubClient);
        repo = service.getRepository(repoOwner, repoName);
        eventService = new EventService(gitHubClient);
    } catch (IOException e) {
        throw new IssueEventException("Can not initialize repo! Check you config!", e);
    }
}
 
开发者ID:stola3,项目名称:github-issue-events-report,代码行数:15,代码来源:IssueEventCollector.java

示例11: getValue

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
public GitHubClient getValue(final HttpContext c) {
    final Optional<String> token = readToken(this.request.getSession(false));
    if(token.isPresent()) {
        final GitHubClient client = new GitHubClient((IGitHubConstants.HOST_DEFAULT.equals(Github.this.githubHostname) ? "api.": "") + Github.this.githubHostname);
        client.setOAuth2Token(token.get());
        return client;
    }
    final URI login = UriBuilder.fromResource(OAuth.class).build();
    throw new WebApplicationException(Response.temporaryRedirect(login).build());
}
 
开发者ID:plan3,项目名称:stoneboard,代码行数:12,代码来源:Github.java

示例12: onActivityCreated

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(R.layout.webview_fragment);
    setContentEmpty(false);
    setContentShown(true);

    View view = getContentView();
    webView = (WebView) view.findViewById(R.id.webview);

    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL);
    webSettings.setSupportZoom(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setDisplayZoomControls(false);

    SharedPreferences preferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE);
    String OAuth = preferences.getString(getString(R.string.login_sp_oauth), null);

    client = new GitHubClient();
    client.setOAuth2Token(OAuth);

    Intent intent = getActivity().getIntent();
    owner = intent.getStringExtra(getString(R.string.webview_intent_owner));
    name = intent.getStringExtra(getString(R.string.webview_intent_name));
    sha = intent.getStringExtra(getString(R.string.webview_intent_sha));
    filename = intent.getStringExtra(getString(R.string.webview_intent_title));

    task = new WebViewTask(WebViewFragment.this);
    task.execute();
}
 
开发者ID:mthli,项目名称:Bitocle,代码行数:36,代码来源:WebViewFragment.java

示例13: onActivityCreated

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    setContentView(R.layout.webview_fragment);
    setContentShown(true);

    View view = getContentView();
    webView = (WebView) view.findViewById(R.id.webview_fragment);
    /* Do something */
    WebSettings webSettings = webView.getSettings();
    webSettings.setBuiltInZoomControls(true);
    webSettings.setJavaScriptEnabled(true);
    webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS.NORMAL);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setLoadsImagesAutomatically(true);
    webSettings.setSupportMultipleWindows(true);
    webSettings.setSupportZoom(true);
    webSettings.setUseWideViewPort(true);

    SharedPreferences sharedPreferences = getActivity().getSharedPreferences(getString(R.string.login_sp), Context.MODE_PRIVATE);
    String oAuth = sharedPreferences.getString(getString(R.string.login_sp_oauth), null);

    gitHubClient = new GitHubClient();
    gitHubClient.setOAuth2Token(oAuth);

    Intent intent = getActivity().getIntent();
    repoOwner = intent.getStringExtra(getString(R.string.content_intent_repoowner));
    repoName = intent.getStringExtra(getString(R.string.content_intent_reponame));
    fileName = intent.getStringExtra(getString(R.string.content_intent_filename));
    sha = intent.getStringExtra(getString(R.string.content_intent_sha));

    webViewTask = new WebViewTask(WebViewFragment.this);
    webViewTask.execute();
}
 
开发者ID:mthli,项目名称:Bitocle,代码行数:35,代码来源:WebViewFragment.java

示例14: initRepositoryService

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
public RepositoryService initRepositoryService() {
    GitHubClient client = new GitHubClient();
    String token = getToken();
    client.setOAuth2Token(token);

    return new RepositoryService(client);
}
 
开发者ID:rgamed,项目名称:jsoup-demo,代码行数:8,代码来源:ARepoLister.java

示例15: doGet

import org.eclipse.egit.github.core.client.GitHubClient; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	String repoName = req.getParameter("repo");
	String auth = req.getParameter("access_token");
	String path = req.getParameter("path");
	String owner = req.getParameter("owner");
	
	GitHubClient client = new GitHubClient();
	client.setOAuth2Token(auth);
	
	RepositoryService repoService = new RepositoryService(client);
	Repository repo = repoService.getRepository(owner, repoName);
	ContentsService contentsService = new ContentsService(client);
	List<RepositoryContents> contents = contentsService.getContents(repo, path);
	
	JSONArray json = new JSONArray();
	
	try {
		for(RepositoryContents file : contents) {
			JSONObject fileJson = new JSONObject();
			fileJson.put("type", file.getType());
			fileJson.put("name", file.getName());
			
			json.put(fileJson);
		}
	} catch(JSONException e) {}
	
	resp.setContentType("application/json");
	resp.getWriter().write(json.toString());
}
 
开发者ID:DeveloperLiberationFront,项目名称:Pdf-Reviewer,代码行数:31,代码来源:FilesServlet.java


注:本文中的org.eclipse.egit.github.core.client.GitHubClient.setOAuth2Token方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。