github/maven-plugins — Issue #7: Authentication is failing when using the API token
Author: acoppes
Created: 2011-11-26 12:54:01+00:00
State: open

I couldn't get authenticated using my Github token instead user/password, the error:

"Listing downloads failed: Bad credentials (401)"

(stacktrace at the end of the issue)

Tried using the org.eclipse.egit.github.core directly with a small test:

public static void main(String[] args) throws IOException {
GitHubClient client = new GitHubClient();
client.setOAuth2Token(MY_PRIVATE_TOKEN);

RepositoryService service = new RepositoryService(client);

Repository repository = service.getRepository("gemserk", "animation4j");

System.out.println("has downloads: " + repository.isHasDownloads());

DownloadService downloadService = new DownloadService(client);

List downloads = downloadService.getDownloads(repository);

for (Download download : downloads) {
System.out.println("download: " + download.getName());
}

}

But failed too, tried changing my Github token and keeps failing. Btw, I own the repository of the example and I already used that API token previously with the maven-github-plugin (https://github.com/kevinpollet/maven-github-plugin).

It worked when using user/pass pair.

Forgive me if I am misunderstanding something about the token.

org.apache.maven.lifecycle.LifecycleExecutionException: Listing downloads failed: Bad credentials (401)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Listing downloads failed: Bad credentials (401)
at com.github.maven.plugins.downloads.DownloadsMojo.getExistingDownloads(DownloadsMojo.java:242)
at com.github.maven.plugins.downloads.DownloadsMojo.execute(DownloadsMojo.java:280)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: org.eclipse.egit.github.core.client.RequestException: Bad credentials (401)
at org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:383)
at org.eclipse.egit.github.core.client.GitHubClient.get(GitHubClient.java:470)
at org.eclipse.egit.github.core.client.PageIterator.next(PageIterator.java:160)
at org.eclipse.egit.github.core.service.GitHubService.getAll(GitHubService.java:136)
at org.eclipse.egit.github.core.service.DownloadService.getDownloads(DownloadService.java:178)
at com.github.maven.plugins.downloads.DownloadsMojo.getExistingDownloads(DownloadsMojo.java:229)
... 20 more