{"issue":{"created_at":"2011-11-26T12:54:01Z","state":"closed","updated_at":"2011-11-27T22:05:43Z","user":{"gravatar_id":"ca2bdbdbe1ffe47ae76401ee91431189","id":591852,"url":"https://api.github.com/users/acoppes","login":"acoppes","avatar_url":"https://secure.gravatar.com/avatar/ca2bdbdbe1ffe47ae76401ee91431189?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":10,"body":"I couldn't get authenticated using my Github token instead user/password, the error:\r\n\r\n\"Listing downloads failed: Bad credentials (401)\"\r\n\r\n(stacktrace at the end of the issue)\r\n\r\nTried using the org.eclipse.egit.github.core directly with a small test:\r\n\r\n\tpublic static void main(String[] args) throws IOException {\r\n\t\tGitHubClient client = new GitHubClient();\r\n\t\tclient.setOAuth2Token(MY_PRIVATE_TOKEN);\r\n\t\t\r\n\t\tRepositoryService service = new RepositoryService(client);\r\n\t\t\r\n\t\tRepository repository = service.getRepository(\"gemserk\", \"animation4j\");\r\n\t\t\r\n\t\tSystem.out.println(\"has downloads: \" + repository.isHasDownloads());\r\n\t\t\r\n\t\tDownloadService downloadService = new DownloadService(client);\r\n\t\t\r\n\t\tList<Download> downloads = downloadService.getDownloads(repository);\r\n\t\t\r\n\t\tfor (Download download : downloads) {\r\n\t\t\tSystem.out.println(\"download: \" + download.getName());\r\n\t\t}\r\n\t\t\r\n\t}\r\n\r\nBut 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). \r\n\r\nIt worked when using user/pass pair.\r\n\r\nForgive me if I am misunderstanding something about the token.\r\n\r\norg.apache.maven.lifecycle.LifecycleExecutionException: Listing downloads failed: Bad credentials (401)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:535)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)\r\n\tat org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)\r\n\tat org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)\r\n\tat org.apache.maven.cli.MavenCli.main(MavenCli.java:362)\r\n\tat org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)\r\n\tat sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)\r\n\tat java.lang.reflect.Method.invoke(Method.java:597)\r\n\tat org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)\r\n\tat org.codehaus.classworlds.Launcher.launch(Launcher.java:255)\r\n\tat org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)\r\n\tat org.codehaus.classworlds.Launcher.main(Launcher.java:375)\r\nCaused by: org.apache.maven.plugin.MojoExecutionException: Listing downloads failed: Bad credentials (401)\r\n\tat com.github.maven.plugins.downloads.DownloadsMojo.getExistingDownloads(DownloadsMojo.java:242)\r\n\tat com.github.maven.plugins.downloads.DownloadsMojo.execute(DownloadsMojo.java:280)\r\n\tat org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)\r\n\tat org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)\r\n\t... 17 more\r\nCaused by: org.eclipse.egit.github.core.client.RequestException: Bad credentials (401)\r\n\tat org.eclipse.egit.github.core.client.GitHubClient.createException(GitHubClient.java:383)\r\n\tat org.eclipse.egit.github.core.client.GitHubClient.get(GitHubClient.java:470)\r\n\tat org.eclipse.egit.github.core.client.PageIterator.next(PageIterator.java:160)\r\n\tat org.eclipse.egit.github.core.service.GitHubService.getAll(GitHubService.java:136)\r\n\tat org.eclipse.egit.github.core.service.DownloadService.getDownloads(DownloadService.java:178)\r\n\tat com.github.maven.plugins.downloads.DownloadsMojo.getExistingDownloads(DownloadsMojo.java:229)\r\n\t... 20 more\r\n\r\n\r\n","assignee":null,"id":2355267,"number":7,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"labels":[],"title":"Authentication is failing when using the API token","closed_at":"2011-11-26T20:48:37Z","html_url":"https://github.com/github/maven-plugins/issues/7","milestone":null,"url":"https://api.github.com/repos/github/maven-plugins/issues/7"},"action":"created","comment":{"created_at":"2011-11-27T22:05:43Z","updated_at":"2011-11-27T22:05:43Z","user":{"gravatar_id":"ca2bdbdbe1ffe47ae76401ee91431189","id":591852,"url":"https://api.github.com/users/acoppes","login":"acoppes","avatar_url":"https://secure.gravatar.com/avatar/ca2bdbdbe1ffe47ae76401ee91431189?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I created an an Oauth2 token with scope repo following the snippet you linked, using that token when uploading artifacts worked perfectly. I will add it to my maven settings for next uploads. \r\n\r\nIf you can use this tokens forever, seems like an interesting feature to have since it is similar to the Github user API token, right?\r\n\r\nThanks for all the help.","id":2890538,"url":"https://api.github.com/repos/github/maven-plugins/issues/comments/2890538"}}