Java Code Examples for org.eclipse.egit.github.core.client.GitHubClient#setOAuth2Token()
The following examples show how to use
org.eclipse.egit.github.core.client.GitHubClient#setOAuth2Token() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GitHubSourceConnector.java From apicurio-studio with Apache License 2.0 | 6 votes |
/** * @throws SourceConnectorException */ private GitHubClient githubClient() throws SourceConnectorException { try { String ghUrl = config.getGitHubApiUrl(); URI url = new URI(ghUrl); String host = url.getHost(); int port = url.getPort(); String scheme = url.getScheme(); GitHubClient client = new GitHubClient(host, port, scheme); String idpToken = getExternalToken(); client.setOAuth2Token(idpToken); return client; } catch (URISyntaxException e) { throw new SourceConnectorException("Error creating the GitHub client.", e); } }
Example 2
Source File: GitHubGovernorClientFactory.java From arquillian-governor with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: IssueReportFix.java From CogniCrypt with Eclipse Public License 2.0 | 5 votes |
/** * sends the {@link Issue} to the eclipse-cognicrypt/CogniCrypt GitHub repository. * * @param issue issue to send */ private void send(Issue issue) { GitHubClient client = new GitHubClient(); client.setOAuth2Token(readToken()); IssueService issueService = new IssueService(client); try { issueService.createIssue("eclipse-cognicrypt", "CogniCrypt", issue); } catch (IOException e) { Activator.getDefault().logError(e); } }
Example 4
Source File: WebViewFragment.java From Bitocle with Apache License 2.0 | 5 votes |
@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(); }
Example 5
Source File: WebViewFragment.java From Bitocle with Apache License 2.0 | 5 votes |
@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(); }
Example 6
Source File: WebViewFragment.java From Bitocle with Apache License 2.0 | 5 votes |
@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(); }
Example 7
Source File: GenerateRoadmapIssuesTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void createIssuesStepB() throws Exception { String accessToken = System.getenv("GitHubAccessToken"); Assume.assumeNotNull("GitHubAccessToken not null", accessToken); GitHubClient client = new GitHubClient(); client.setOAuth2Token(accessToken); String githubUser = "wildfly-extras"; String githubRepo = "wildfly-camel"; Milestone milestone = null; MilestoneService milestoneService = new MilestoneService(client); for (Milestone aux : milestoneService.getMilestones(githubUser, githubRepo, IssueService.STATE_OPEN)) { if (aux.getTitle().equals(MILESTONE)) { milestone = aux; break; } } Assert.assertNotNull("Milestone not null", milestone); IssueService issueService = new IssueService(client); try (BufferedReader br = new BufferedReader(new FileReader(auxfile.toFile()))) { String line = br.readLine(); while (line != null) { String title = "Add support for " + line; System.out.println(title); Issue issue = new Issue(); issue.setTitle(title); issue.setLabels(Collections.singletonList(LABEL)); issue.setMilestone(milestone); issueService.createIssue(githubUser, githubRepo, issue); line = br.readLine(); Thread.sleep(3 * 1000); } } }
Example 8
Source File: GitHubTemplate.java From service-block-samples with Apache License 2.0 | 4 votes |
private void authenticate() { client = new GitHubClient(); client.setOAuth2Token(gitHubProperties.getAccessToken()); }