Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub OAuth returned 500 Internal Server Error #289

Closed
yuyueugene84 opened this issue Mar 6, 2019 · 9 comments · Fixed by #359
Closed

GitHub OAuth returned 500 Internal Server Error #289

yuyueugene84 opened this issue Mar 6, 2019 · 9 comments · Fixed by #359
Labels
bug Something isn't working support Support questions (should be on discourse.jupyter.org instead)
Milestone

Comments

@yuyueugene84
Copy link

I set up the Github Oauth using this guide

But after I tried to login with github, Jupyterhub kept showing the following error:

Mar 06 16:32:25 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:32:25.526 JupyterHub proxy:301] Checking routes
Mar 06 16:32:25 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:32:25.554 JupyterHub oauth2:82] OAuth redirect: 'https://codesaviour.com/hub/oauth_callback'
Mar 06 16:32:25 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:32:25.555 JupyterHub log:158] 302 GET /hub/oauth_login?next= -> https://github.com/login/oauth/authorize?response_type=code&redirect_uri=https%3A%2F%2Fcodesaviour.com%2Fhub%2Foauth_callback&client_id=99394b3c47f15ebef8ab&state=[secret] (@150.116.31.66) 1.91ms
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]: [E 2019-03-06 16:32:28.432 JupyterHub web:1788] Uncaught exception GET /hub/oauth_callback?code=efcd6e16b2756af9f307&state=eyJzdGF0ZV9pZCI6ICIzYTQ2M2UxOWJjMzE0NTVlOTJiM2E0YmM1ZWFiYjE2NCIsICJuZXh0X3VybCI6ICIifQ%3D%3D (150.116.31.66)
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:     HTTPServerRequest(protocol='https', host='codesaviour.com', method='GET', uri='/hub/oauth_callback?code=efcd6e16b2756af9f307&state=eyJzdGF0ZV9pZCI6ICIzYTQ2M2UxOWJjMzE0NTVlOTJiM2E0YmM1ZWFiYjE2NCIsICJuZXh0X3VybCI6ICIifQ%3D%3D', version='HTTP/1.1', remote_ip='150.116.31.66')
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:     Traceback (most recent call last):
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       File "/opt/tljh/hub/lib/python3.6/site-packages/tornado/web.py", line 1699, in _execute
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:         result = await result
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       File "/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/oauth2.py", line 182, in get
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:         user = yield self.login_user()
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       File "/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/handlers/base.py", line 473, in login_user
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:         authenticated = await self.authenticate(data)
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       File "/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/auth.py", line 257, in get_authenticated_user
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:         authenticated = await maybe_future(self.authenticate(handler, data))
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       File "/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/github.py", line 116, in authenticate
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:         resp = yield http_client.fetch(req)
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:     tornado.simple_httpclient.HTTPStreamClosedError: Stream closed
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]: [E 2019-03-06 16:32:28.436 JupyterHub log:150] {
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Host": "codesaviour.com",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Accept-Encoding": "gzip, deflate, br",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Accept-Language": "en-US,en;q=0.9,zh-TW;q=0.8,zh;q=0.7,zh-CN;q=0.6",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Alexatoolbar-Alx_ns_ph": "AlexaToolbar/alx-4.0.3",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Cookie": "oauthenticator-state=\"2|1:0|10:1551889945|20:oauthenticator-state|120:ZXlKemRHRjBaVjlwWkNJNklDSXpZVFEyTTJVeE9XSmpNekUwTlRWbE9USmlNMkUwWW1NMVpXRmlZakUyTkNJc0lDSnVaWGgwWDNWeWJDSTZJQ0lpZlE9PQ==|0cbd6ee0cfa185504350fe5cae06dbfb781a45e03bf6afe77eb3b0a9f248aa25\"",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Referer": "https://codesaviour.com/hub/login",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "Upgrade-Insecure-Requests": "1",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "X-Forwarded-For": "150.116.31.66",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "X-Forwarded-Host": "codesaviour.com",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "X-Forwarded-Port": "443",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "X-Forwarded-Proto": "https",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "X-Forwarded-Server": "ip-172-31-13-75",
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:       "X-Real-Ip": "150.116.31.66"
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]:     }
Mar 06 16:32:28 ip-172-31-13-75 python3[1738]: [E 2019-03-06 16:32:28.437 JupyterHub log:158] 500 GET /hub/oauth_callback?code=[secret]&state=[secret] (@150.116.31.66) 503.26ms
Mar 06 16:33:44 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:33:44.486 JupyterHub log:158] 302 GET / -> /hub (@150.116.31.66) 1.22ms
Mar 06 16:33:44 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:33:44.614 JupyterHub log:158] 302 GET /hub -> /hub/ (@150.116.31.66) 0.87ms
Mar 06 16:33:44 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:33:44.719 JupyterHub log:158] 302 GET /hub/ -> /user/kyosei/ (kyosei@150.116.31.66) 9.44ms
Mar 06 16:33:45 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:33:45.055 JupyterHub log:158] 302 GET /hub/api/oauth2/authorize?client_id=jupyterhub-user-kyosei&redirect_uri=%2Fuser%2Fkyosei%2Foauth_callback&response_type=code&state=[secret] -> /user/kyosei/oauth_callback?code=[secret]&state=[secret] (kyosei@150.116.31.66) 18.76ms
Mar 06 16:33:45 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:33:45.182 JupyterHub log:158] 200 POST /hub/api/oauth2/token (kyosei@127.0.0.1) 26.63ms
Mar 06 16:33:45 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:33:45.211 JupyterHub log:158] 200 GET /hub/api/authorizations/token/[secret] (kyosei@127.0.0.1) 20.24ms
Mar 06 16:37:25 ip-172-31-13-75 python3[1738]: [I 2019-03-06 16:37:25.526 JupyterHub proxy:301] Checking routes
@gpvidal
Copy link

gpvidal commented Mar 10, 2019

I had the same issue, to fix this:

pip3 install tornado==5.1.1

Source: jupyterhub/jupyterhub#2448 (comment)

@willirath
Copy link
Collaborator

I'd hope that this is fixed with #292.

@yuyueugene84
Copy link
Author

yuyueugene84 commented Mar 13, 2019

@willirath @gpvidal The same problem still exists after I installed the newest versioin, I already changed my tornado version to 5.1.1:
Screen Shot 2019-03-13 at 2 50 56 PM

I checked the error log when I tried to login with github:

Mar 13 06:49:05 ip-172-31-45-199 python3[1227]: [I 2019-03-13 06:49:05.488 JupyterHub log:158] 302 GET /hub/ -> /hub/login (@1.160.48.197) 0.58ms
Mar 13 06:49:07 ip-172-31-45-199 python3[1227]: [I 2019-03-13 06:49:07.404 JupyterHub oauth2:82] OAuth redirect: 'https://codesaviour.com/hub/oauth_callback'
Mar 13 06:49:07 ip-172-31-45-199 python3[1227]: [I 2019-03-13 06:49:07.404 JupyterHub log:158] 302 GET /hub/oauth_login?next= -> https://github.com/login/oauth/authorize?response_type=code&redirect_uri=https%3A%2F%2Fcodesaviour.com%2Fhub%2Foauth_callback&client_id=d70b47b4034dd71e0e56&state=[secret] (@1.160.48.197) 2.85ms
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]: [E 2019-03-13 06:49:08.250 JupyterHub web:1788] Uncaught exception GET /hub/oauth_callback?code=5cc18b863c1bdd406985&state=eyJzdGF0ZV9pZCI6ICJmYjVjN2JlN2ZjNDU0MzUzOGJmNDViODIwOTgzNDIwYyIsICJuZXh0X3VybCI6ICIifQ%3D%3D (1.160.48.197)
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:     HTTPServerRequest(protocol='https', host='codesaviour.com', method='GET', uri='/hub/oauth_callback?code=5cc18b863c1bdd406985&state=eyJzdGF0ZV9pZCI6ICJmYjVjN2JlN2ZjNDU0MzUzOGJmNDViODIwOTgzNDIwYyIsICJuZXh0X3VybCI6ICIifQ%3D%3D', version='HTTP/1.1', remote_ip='1.160.48.197')
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:     Traceback (most recent call last):
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       File "/opt/tljh/hub/lib/python3.6/site-packages/tornado/web.py", line 1699, in _execute
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:         result = await result
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       File "/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/oauth2.py", line 182, in get
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:         user = yield self.login_user()
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       File "/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/handlers/base.py", line 473, in login_user
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:         authenticated = await self.authenticate(data)
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       File "/opt/tljh/hub/lib/python3.6/site-packages/jupyterhub/auth.py", line 257, in get_authenticated_user
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:         authenticated = await maybe_future(self.authenticate(handler, data))
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       File "/opt/tljh/hub/lib/python3.6/site-packages/oauthenticator/github.py", line 116, in authenticate
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:         resp = yield http_client.fetch(req)
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:     tornado.simple_httpclient.HTTPStreamClosedError: Stream closed
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]: [E 2019-03-13 06:49:08.252 JupyterHub log:150] {
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Host": "codesaviour.com",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Accept-Encoding": "gzip, deflate, br",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Accept-Language": "en-US,en;q=0.9,zh-TW;q=0.8,zh;q=0.7,zh-CN;q=0.6",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Cookie": "oauthenticator-state=\"2|1:0|10:1552459747|20:oauthenticator-state|120:ZXlKemRHRjBaVjlwWkNJNklDSm1ZalZqTjJKbE4yWmpORFUwTXpVek9HSm1ORFZpT0RJd09UZ3pOREl3WXlJc0lDSnVaWGgwWDNWeWJDSTZJQ0lpZlE9PQ==|df97c3aa8ab4632fd2fbbc952abd86deff342a8807184215f7024a1b8fa47575\"",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Referer": "https://codesaviour.com/hub/login",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "Upgrade-Insecure-Requests": "1",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "X-Forwarded-For": "1.160.48.197",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "X-Forwarded-Host": "codesaviour.com",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "X-Forwarded-Port": "443",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "X-Forwarded-Proto": "https",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "X-Forwarded-Server": "ip-172-31-45-199",
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:       "X-Real-Ip": "1.160.48.197"
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]:     }
Mar 13 06:49:08 ip-172-31-45-199 python3[1227]: [E 2019-03-13 06:49:08.252 JupyterHub log:158] 500 GET /hub/oauth_callback?code=[secret]&state=[secret] (@1.160.48.197) 514.92ms
Mar 13 06:49:22 ip-172-31-45-199 python3[1227]: [I 2019-03-13 06:49:22.208 JupyterHub proxy:301] Checking routes
Mar 13 06:51:08 ip-172-31-45-199 python3[1227]: [I 2019-03-13 06:51:08.294 JupyterHub log:158] 200 GET /hub/api/authorizations/token/[secret] (kyosei@127.0.0.1) 17.07ms

I'm not sure if I missing any steps or configuration, do I have to create an user with the same username as my github account before I use github authentication? Or are there extra steps reqiured so that Jupyterhub will create a local user when github authenication is successful?

@andrewresearch
Copy link

I have the same issue with GitHub Auth - Is there a workaround?
tornado 5.1.1 does not fix.

@leportella leportella added the bug Something isn't working label Mar 22, 2019
@carlthewebmaster
Copy link

I had this exact issue. It turned out I was upgrading the wrong Tornado. Per
this link,

JupyterHub is run from a python3 virtual environment located in /opt/tljh/hub

That was the clue I needed - Once I got into that virutal environment:

$ sudo su -
# cd /opt/tljh/hub
# source ./bin/activate
# pip3 freeze | grep tornado
tornado==6.0.2
# pip3 install tornado==5.1.1
# pip3 freeze | grep tornado
tornado==5.1.1
# exit
$ sudo tljh-config reload proxy
$ sudo tljh-config reload

Worked!

@yuvipanda
Copy link
Collaborator

#313 bumps oauthenticator, so maybe that'll help too. Are you still having this issue, @andrewresearch @yuyueugene84?

@yuvipanda yuvipanda added support Support questions (should be on discourse.jupyter.org instead) and removed bug Something isn't working labels May 20, 2019
@yuyueugene84
Copy link
Author

@yuvipanda I have tried that and it still does not fix the issue, so I swtiched back to the original jupyterhub instead, thanks anyway for the concern.

@yuvipanda
Copy link
Collaborator

I was able to reproduce this today. It looks like the cause is tornado's SimpleHTTPClient.

Installing pycurl in the hub environment fixed it. We should ship with that by default.

@yuvipanda yuvipanda added the bug Something isn't working label May 29, 2019
@yuvipanda yuvipanda added this to the v1.0 milestone May 29, 2019
yuvipanda added a commit to yuvipanda/the-littlest-jupyterhub that referenced this issue May 29, 2019
It's generally more bugfree and performant.
We install dependencies of pycurl, including build-essential.
build-essential is used by many other dependencies
as well - particularly psutil for nbresuse.

Fixes jupyterhub#289
Fixes jupyterhub#286
@yuvipanda
Copy link
Collaborator

This should be fixed now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working support Support questions (should be on discourse.jupyter.org instead)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants