|
22 | 22 | import org.apache.commons.io.IOUtils;
|
23 | 23 | import org.commonwl.viewer.domain.GithubDetails;
|
24 | 24 | import org.eclipse.egit.github.core.*;
|
| 25 | +import org.eclipse.egit.github.core.RepositoryContents; |
| 26 | +import org.eclipse.egit.github.core.RepositoryId; |
| 27 | +import org.eclipse.egit.github.core.User; |
25 | 28 | import org.eclipse.egit.github.core.client.GitHubClient;
|
26 | 29 | import org.eclipse.egit.github.core.service.CommitService;
|
27 | 30 | import org.eclipse.egit.github.core.service.ContentsService;
|
@@ -53,12 +56,15 @@ public class GitHubService {
|
53 | 56 | private final Pattern githubDirPattern = Pattern.compile(GITHUB_DIR_REGEX);
|
54 | 57 |
|
55 | 58 | @Autowired
|
56 |
| - public GitHubService(@Value("${githubAPI.authentication}") boolean authEnabled, |
| 59 | + public GitHubService(@Value("${githubAPI.authentication}") String authSetting, |
| 60 | + @Value("${githubAPI.oauthToken}") String token, |
57 | 61 | @Value("${githubAPI.username}") String username,
|
58 | 62 | @Value("${githubAPI.password}") String password) {
|
59 | 63 | GitHubClient client = new GitHubClient();
|
60 |
| - if (authEnabled) { |
| 64 | + if (authSetting.equals("basic")) { |
61 | 65 | client.setCredentials(username, password);
|
| 66 | + } else if (authSetting.equals("oauth")) { |
| 67 | + client.setOAuth2Token(token); |
62 | 68 | }
|
63 | 69 | this.contentsService = new ContentsService(client);
|
64 | 70 | this.userService = new UserService(client);
|
|
0 commit comments