mocleiri/github-oauth-plugin — Issue #16: Authentication Fails on Github Enterprise
Author: virtix
Created: 2012-01-31 16:02:35+00:00
State: open

Hi there,

New user here. Thanks for the plugin!

Authentication works OK if I use github.com but fails on our Github Enterprise install. I created an OAuth App:

URL: http://ourserver.foo.local:8080/jenkins/
Callback: http://ourserver.foo.local:8080/jenkins/securityRealm/finishLogin
Client ID: f489af209ffc751042b1
Client Secret: f31500110d44d0ccc40fd922dfe78e7b00b2d263

When I click 'login' on the Jenkins screen, I'm redirected to Github Enterprise, I authenticate, and am asked to allow the app. Then boom (see below):

Any ideas?

```
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

java.io.IOException: {"error":"Couldn't authenticate you"}
org.kohsuke.github.GitHub.handleApiError(GitHub.java:215)
org.kohsuke.github.GitHub._retrieve(GitHub.java:190)
org.kohsuke.github.GitHub.retrieveWithAuth(GitHub.java:160)
org.kohsuke.github.GitHub.retrieveWithAuth(GitHub.java:152)
org.kohsuke.github.GitHub.getMyself(GitHub.java:227)
org.kohsuke.github.GitHub.(GitHub.java:91)
org.kohsuke.github.GitHub.connectUsingOAuth(GitHub.java:118)
org.jenkinsci.plugins.GithubAuthenticationToken.(GithubAuthenticationToken.java:68)
org.jenkinsci.plugins.GithubSecurityRealm.doFinishLogin(GithubSecurityRealm.java:310)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:282)
org.kohsuke.stapler.Function.bindAndInvoke(Function.java:149)
org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:88)
org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:203)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:477)
org.kohsuke.stapler.Stapler.service(Stapler.java:159)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:95)
hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:87)
hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:47)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
org.acegisecurity.ui.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:166)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
org.acegisecurity.ui.basicauth.BasicProcessingFilter.doFilter(BasicProcessingFilter.java:173)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
jenkins.security.ApiTokenFilter.doFilter(ApiTokenFilter.java:61)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:66)
hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
hudson.security.HudsonFilter.doFilter(HudsonFilter.java:164)
hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
root cause

java.io.IOException: Server returned HTTP response code: 401 for URL: https://github.com/api/v2/json/user/show?access_token=296ae0c9426fc11b9ea4322c5dc9008d436c28b8
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1436)
sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
org.kohsuke.github.GitHub._retrieve(GitHub.java:183)
org.kohsuke.github.GitHub.retrieveWithAuth(GitHub.java:160)
org.kohsuke.github.GitHub.retrieveWithAuth(GitHub.java:152)
org.kohsuke.github.GitHub.getMyself(GitHub.java:227)
org.kohsuke.github.GitHub.(GitHub.java:91)
org.kohsuke.github.GitHub.connectUsingOAuth(GitHub.java:118)
org.jenkinsci.plugins.GithubAuthenticationToken.(GithubAuthenticationToken.java:68)
org.jenkinsci.plugins.GithubSecurityRealm.doFinishLogin(GithubSecurityRealm.java:310)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:282)
org.kohsuke.stapler.Function.bindAndInvoke(Function.java:149)
org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:88)
org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:111)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
org.kohsuke.stapler.MetaClass$4.doDispatch(MetaClass.java:203)
org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:53)
org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:563)
org.kohsuke.stapler.Stapler.invoke(Stapler.java:648)
```