question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GitHub OAuth returned 500 Internal Server Error

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
yuvipandacommented, May 29, 2019

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.

1reaction
carlthewebmastercommented, Apr 24, 2019

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

GitHub Oauth returning 500 "Internal Server Error" when ...
This fails with a specific GitHub account and works with another. ... "Internal Server Error" is returned, web app does not authenticate.
Read more >
OAuth refresh grant returns 500 internal server error #1533
A 200 response with a JSON object in the body containing a new, valid access token. Observed result. An internal error. Should this...
Read more >
Authentication fails with a 500 internal server error · Issue #5978
I've attempted debugging with GH_DEBUG=api , but I see no actual 500s being returned. The last request I see before the error message...
Read more >
500 Internal Server Error on /api/auth/signin, cannot ... - GitHub
my implementation works locally, but when creating a github oauth for production with nextauth-secret, production callback url. I get a 500 to / ......
Read more >
http error 500 when trying to link accounts via oauth #19715
Try to login using the provider via the Login Screen of your instance. At first it will redirect correctly to gitlab, but when...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found