I’m trying to integrate JupyterHub with GitLab using OAuth. When I look at the JupyterHub logs, I continually encounter two errors: “400 Bad Request OAuth state missing from cookies” and “Error fetching 599 POST http://172.19.238.185:9080/oauth/token: HTTP 599: Connection timed out after 20001 milliseconds.”
I am currently using WSL2, and I have attached my environment and code details. Please help.
<code>[ jupyterhub error log ]
[E 2024-05-09 08:07:31.418 JupyterHub oauth2:653] Error fetching 599 POST http://172.19.238.185:9080/oauth/token: HTTP 599: Connection timed out after 20001 milliseconds
[E 2024-05-09 08:07:31.418 JupyterHub web:1875] Uncaught exception GET /hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9 (::ffff:192.168.240.1)
HTTPServerRequest(protocol='https', host='www.gitlab.example.com:8443', method='GET', uri='/hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9', version='HTTP/1.1', remote_ip='::ffff:192.168.240.1')
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tornado/web.py", line 1790, in _execute
result = await result
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 210, in get
user = await self.login_user()
File "/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py", line 928, in login_user
authenticated = await self.authenticate(data)
File "/usr/local/lib/python3.10/dist-packages/jupyterhub/auth.py", line 493, in get_authenticated_user
authenticated = await maybe_future(self.authenticate(handler, data))
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 1029, in authenticate
token_info = await self.get_token_info(handler, access_token_params)
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 874, in get_token_info
token_info = await self.httpfetch(
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 688, in httpfetch
return await self.fetch(
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 654, in fetch
raise e
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 633, in fetch
resp = await self.http_client.fetch(req, **kwargs)
tornado.curl_httpclient.CurlError: HTTP 599: Connection timed out after 20001 milliseconds
[I 2024-05-09 08:07:31.419 JupyterHub _xsrf_utils:125] Setting new xsrf cookie for b'None:NgfnePWlIjz1DeW9VtMxA7IUHWMF_A4-VC0vzKbXkbs=' {'path': '/hub/', 'max_age': 3600}
[E 2024-05-09 08:07:31.439 JupyterHub log:184] {
"X-Forwarded-Host": "www.gitlab.example.com:8443",
"X-Forwarded-Proto": "https",
"X-Forwarded-Port": "8443",
"X-Forwarded-For": "::ffff:192.168.240.1",
"Cookie": "_xsrf=[secret]; preferred_language=[secret]; oauthenticator-state=[secret]; known_sign_in=[secret]; _gitlab_session=[secret]",
"Accept-Language": "ko,en;q=0.9,en-US;q=0.8",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Referer": "https://www.gitlab.example.com/",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "same-site",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0",
"Upgrade-Insecure-Requests": "1",
"Sec-Ch-Ua-Platform": ""Windows"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua": ""Microsoft Edge";v="123", "Not:A-Brand";v="8", "Chromium";v="123"",
"Connection": "keep-alive",
"Host": "www.gitlab.example.com:8443"
}
[E 2024-05-09 08:07:31.439 JupyterHub log:192] 500 GET /hub/oauth_callback?code=[secret]&state=[secret] (@::ffff:192.168.240.1) 20023.17ms
[W 2024-05-09 08:08:43.135 JupyterHub web:1873] 400 GET /hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9 (::ffff:192.168.240.1): OAuth state missing from cookies
[W 2024-05-09 08:08:43.136 JupyterHub log:192] 400 GET /hub/oauth_callback?code=[secret]&state=[secret] (@::ffff:192.168.240.1) 1.64ms
</code>
<code>[ jupyterhub error log ]
[E 2024-05-09 08:07:31.418 JupyterHub oauth2:653] Error fetching 599 POST http://172.19.238.185:9080/oauth/token: HTTP 599: Connection timed out after 20001 milliseconds
[E 2024-05-09 08:07:31.418 JupyterHub web:1875] Uncaught exception GET /hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9 (::ffff:192.168.240.1)
HTTPServerRequest(protocol='https', host='www.gitlab.example.com:8443', method='GET', uri='/hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9', version='HTTP/1.1', remote_ip='::ffff:192.168.240.1')
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tornado/web.py", line 1790, in _execute
result = await result
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 210, in get
user = await self.login_user()
File "/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py", line 928, in login_user
authenticated = await self.authenticate(data)
File "/usr/local/lib/python3.10/dist-packages/jupyterhub/auth.py", line 493, in get_authenticated_user
authenticated = await maybe_future(self.authenticate(handler, data))
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 1029, in authenticate
token_info = await self.get_token_info(handler, access_token_params)
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 874, in get_token_info
token_info = await self.httpfetch(
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 688, in httpfetch
return await self.fetch(
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 654, in fetch
raise e
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 633, in fetch
resp = await self.http_client.fetch(req, **kwargs)
tornado.curl_httpclient.CurlError: HTTP 599: Connection timed out after 20001 milliseconds
[I 2024-05-09 08:07:31.419 JupyterHub _xsrf_utils:125] Setting new xsrf cookie for b'None:NgfnePWlIjz1DeW9VtMxA7IUHWMF_A4-VC0vzKbXkbs=' {'path': '/hub/', 'max_age': 3600}
[E 2024-05-09 08:07:31.439 JupyterHub log:184] {
"X-Forwarded-Host": "www.gitlab.example.com:8443",
"X-Forwarded-Proto": "https",
"X-Forwarded-Port": "8443",
"X-Forwarded-For": "::ffff:192.168.240.1",
"Cookie": "_xsrf=[secret]; preferred_language=[secret]; oauthenticator-state=[secret]; known_sign_in=[secret]; _gitlab_session=[secret]",
"Accept-Language": "ko,en;q=0.9,en-US;q=0.8",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Referer": "https://www.gitlab.example.com/",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "same-site",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0",
"Upgrade-Insecure-Requests": "1",
"Sec-Ch-Ua-Platform": ""Windows"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua": ""Microsoft Edge";v="123", "Not:A-Brand";v="8", "Chromium";v="123"",
"Connection": "keep-alive",
"Host": "www.gitlab.example.com:8443"
}
[E 2024-05-09 08:07:31.439 JupyterHub log:192] 500 GET /hub/oauth_callback?code=[secret]&state=[secret] (@::ffff:192.168.240.1) 20023.17ms
[W 2024-05-09 08:08:43.135 JupyterHub web:1873] 400 GET /hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9 (::ffff:192.168.240.1): OAuth state missing from cookies
[W 2024-05-09 08:08:43.136 JupyterHub log:192] 400 GET /hub/oauth_callback?code=[secret]&state=[secret] (@::ffff:192.168.240.1) 1.64ms
</code>
[ jupyterhub error log ]
[E 2024-05-09 08:07:31.418 JupyterHub oauth2:653] Error fetching 599 POST http://172.19.238.185:9080/oauth/token: HTTP 599: Connection timed out after 20001 milliseconds
[E 2024-05-09 08:07:31.418 JupyterHub web:1875] Uncaught exception GET /hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9 (::ffff:192.168.240.1)
HTTPServerRequest(protocol='https', host='www.gitlab.example.com:8443', method='GET', uri='/hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9', version='HTTP/1.1', remote_ip='::ffff:192.168.240.1')
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tornado/web.py", line 1790, in _execute
result = await result
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 210, in get
user = await self.login_user()
File "/usr/local/lib/python3.10/dist-packages/jupyterhub/handlers/base.py", line 928, in login_user
authenticated = await self.authenticate(data)
File "/usr/local/lib/python3.10/dist-packages/jupyterhub/auth.py", line 493, in get_authenticated_user
authenticated = await maybe_future(self.authenticate(handler, data))
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 1029, in authenticate
token_info = await self.get_token_info(handler, access_token_params)
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 874, in get_token_info
token_info = await self.httpfetch(
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 688, in httpfetch
return await self.fetch(
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 654, in fetch
raise e
File "/usr/local/lib/python3.10/dist-packages/oauthenticator/oauth2.py", line 633, in fetch
resp = await self.http_client.fetch(req, **kwargs)
tornado.curl_httpclient.CurlError: HTTP 599: Connection timed out after 20001 milliseconds
[I 2024-05-09 08:07:31.419 JupyterHub _xsrf_utils:125] Setting new xsrf cookie for b'None:NgfnePWlIjz1DeW9VtMxA7IUHWMF_A4-VC0vzKbXkbs=' {'path': '/hub/', 'max_age': 3600}
[E 2024-05-09 08:07:31.439 JupyterHub log:184] {
"X-Forwarded-Host": "www.gitlab.example.com:8443",
"X-Forwarded-Proto": "https",
"X-Forwarded-Port": "8443",
"X-Forwarded-For": "::ffff:192.168.240.1",
"Cookie": "_xsrf=[secret]; preferred_language=[secret]; oauthenticator-state=[secret]; known_sign_in=[secret]; _gitlab_session=[secret]",
"Accept-Language": "ko,en;q=0.9,en-US;q=0.8",
"Accept-Encoding": "gzip, deflate, br, zstd",
"Referer": "https://www.gitlab.example.com/",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "same-site",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0",
"Upgrade-Insecure-Requests": "1",
"Sec-Ch-Ua-Platform": ""Windows"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua": ""Microsoft Edge";v="123", "Not:A-Brand";v="8", "Chromium";v="123"",
"Connection": "keep-alive",
"Host": "www.gitlab.example.com:8443"
}
[E 2024-05-09 08:07:31.439 JupyterHub log:192] 500 GET /hub/oauth_callback?code=[secret]&state=[secret] (@::ffff:192.168.240.1) 20023.17ms
[W 2024-05-09 08:08:43.135 JupyterHub web:1873] 400 GET /hub/oauth_callback?code=6266fd4b33deec46e72239e1f876d3a4751ab968682d9c67740f7d916f98c0f4&state=eyJzdGF0ZV9pZCI6ICIxMWE4NjNkNzJmMWQ0OGM4OWRlZThhMjFkYjdjOTEzNSJ9 (::ffff:192.168.240.1): OAuth state missing from cookies
[W 2024-05-09 08:08:43.136 JupyterHub log:192] 400 GET /hub/oauth_callback?code=[secret]&state=[secret] (@::ffff:192.168.240.1) 1.64ms
<code>[ hosts ]
172.19.238.185 www.gitlab.example.com
</code>
<code>[ hosts ]
172.19.238.185 www.gitlab.example.com
</code>
[ hosts ]
172.19.238.185 www.gitlab.example.com
<code>[ docker-compose.yml ]
version: '3.8'
services:
jupyterhub:
image: jupyterhub1
container_name: jupyterhub
restart: always
ports:
- '8443:443'
command: jupyterhub
stdin_open: true
tty: true
depends_on:
- gitlab
volumes:
- ../openssl/server.crt:/etc/jupyterhub/ssl/server.crt
- ../openssl/server.key:/etc/jupyterhub/ssl/server.key
- ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
networks:
- internal_network
gitlab:
image: gitlab
container_name: gitlab
restart: always
hostname: www.gitlab.example.com
ports:
- '443:443'
- '9080:80'
- '10022:22'
volumes:
- ./gitlab.rb:/etc/gitlab/gitlab.rb
- /var/gitlab/config:/etc/gitlab
- /var/gitlab/logs:/var/log/gitlab
- /var/gitlab/data:/var/opt/gitlab
- ../openssl/server.crt:/etc/gitlab/ssl/server.crt
- ../openssl/server.key:/etc/gitlab/ssl/server.key
networks:
- internal_network
networks:
internal_network:
driver: bridge
</code>
<code>[ docker-compose.yml ]
version: '3.8'
services:
jupyterhub:
image: jupyterhub1
container_name: jupyterhub
restart: always
ports:
- '8443:443'
command: jupyterhub
stdin_open: true
tty: true
depends_on:
- gitlab
volumes:
- ../openssl/server.crt:/etc/jupyterhub/ssl/server.crt
- ../openssl/server.key:/etc/jupyterhub/ssl/server.key
- ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
networks:
- internal_network
gitlab:
image: gitlab
container_name: gitlab
restart: always
hostname: www.gitlab.example.com
ports:
- '443:443'
- '9080:80'
- '10022:22'
volumes:
- ./gitlab.rb:/etc/gitlab/gitlab.rb
- /var/gitlab/config:/etc/gitlab
- /var/gitlab/logs:/var/log/gitlab
- /var/gitlab/data:/var/opt/gitlab
- ../openssl/server.crt:/etc/gitlab/ssl/server.crt
- ../openssl/server.key:/etc/gitlab/ssl/server.key
networks:
- internal_network
networks:
internal_network:
driver: bridge
</code>
[ docker-compose.yml ]
version: '3.8'
services:
jupyterhub:
image: jupyterhub1
container_name: jupyterhub
restart: always
ports:
- '8443:443'
command: jupyterhub
stdin_open: true
tty: true
depends_on:
- gitlab
volumes:
- ../openssl/server.crt:/etc/jupyterhub/ssl/server.crt
- ../openssl/server.key:/etc/jupyterhub/ssl/server.key
- ./jupyterhub_config.py:/srv/jupyterhub/jupyterhub_config.py
networks:
- internal_network
gitlab:
image: gitlab
container_name: gitlab
restart: always
hostname: www.gitlab.example.com
ports:
- '443:443'
- '9080:80'
- '10022:22'
volumes:
- ./gitlab.rb:/etc/gitlab/gitlab.rb
- /var/gitlab/config:/etc/gitlab
- /var/gitlab/logs:/var/log/gitlab
- /var/gitlab/data:/var/opt/gitlab
- ../openssl/server.crt:/etc/gitlab/ssl/server.crt
- ../openssl/server.key:/etc/gitlab/ssl/server.key
networks:
- internal_network
networks:
internal_network:
driver: bridge
<code>[ gitlab.rb ]
gitlab_rails['gitlab_shell_ssh_port'] = 10022
external_url 'https://www.gitlab.example.com'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"
</code>
<code>[ gitlab.rb ]
gitlab_rails['gitlab_shell_ssh_port'] = 10022
external_url 'https://www.gitlab.example.com'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"
</code>
[ gitlab.rb ]
gitlab_rails['gitlab_shell_ssh_port'] = 10022
external_url 'https://www.gitlab.example.com'
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/server.crt"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/server.key"
<code>[jupyterhub_config.py]
from oauthenticator.gitlab import GitLabOAuthenticator
c = get_config() #noqa
c.Spawner.default_url = '/lab'
c.JupyterHub.authenticator_class = GitLabOAuthenticator
c.GitLabOAuthenticator.oauth_access_token_url = 'https://www.gitlab.example.com/oauth/token'
c.GitLabOAuthenticator.oauth_callback_url = 'https://www.gitlab.example.com:8443/hub/oauth_callback'
c.GitLabOAuthenticator.client_id = '75332de9e109185387a2d1224f715b93eeea0662b455e162e7922b38b023bdcb'
c.GitLabOAuthenticator.client_secret = 'gloas-16d6fa103ff0c4a3d7c0b4a9b1e5b167645632ac2475d891f9f4654103ea45ac'
c.GitLabOAuthenticator.gitlab_host = 'https://www.gitlab.example.com'
c.JupyterHub.port = 443
c.JupyterHub.ssl_key = '/etc/jupyterhub/ssl/server.key'
c.JupyterHub.ssl_cert = '/etc/jupyterhub/ssl/server.crt'
c.Authenticator.admin_users = {'admin'}
c.PAMAuthenticator.admin_groups = {'masterG'}
</code>
<code>[jupyterhub_config.py]
from oauthenticator.gitlab import GitLabOAuthenticator
c = get_config() #noqa
c.Spawner.default_url = '/lab'
c.JupyterHub.authenticator_class = GitLabOAuthenticator
c.GitLabOAuthenticator.oauth_access_token_url = 'https://www.gitlab.example.com/oauth/token'
c.GitLabOAuthenticator.oauth_callback_url = 'https://www.gitlab.example.com:8443/hub/oauth_callback'
c.GitLabOAuthenticator.client_id = '75332de9e109185387a2d1224f715b93eeea0662b455e162e7922b38b023bdcb'
c.GitLabOAuthenticator.client_secret = 'gloas-16d6fa103ff0c4a3d7c0b4a9b1e5b167645632ac2475d891f9f4654103ea45ac'
c.GitLabOAuthenticator.gitlab_host = 'https://www.gitlab.example.com'
c.JupyterHub.port = 443
c.JupyterHub.ssl_key = '/etc/jupyterhub/ssl/server.key'
c.JupyterHub.ssl_cert = '/etc/jupyterhub/ssl/server.crt'
c.Authenticator.admin_users = {'admin'}
c.PAMAuthenticator.admin_groups = {'masterG'}
</code>
[jupyterhub_config.py]
from oauthenticator.gitlab import GitLabOAuthenticator
c = get_config() #noqa
c.Spawner.default_url = '/lab'
c.JupyterHub.authenticator_class = GitLabOAuthenticator
c.GitLabOAuthenticator.oauth_access_token_url = 'https://www.gitlab.example.com/oauth/token'
c.GitLabOAuthenticator.oauth_callback_url = 'https://www.gitlab.example.com:8443/hub/oauth_callback'
c.GitLabOAuthenticator.client_id = '75332de9e109185387a2d1224f715b93eeea0662b455e162e7922b38b023bdcb'
c.GitLabOAuthenticator.client_secret = 'gloas-16d6fa103ff0c4a3d7c0b4a9b1e5b167645632ac2475d891f9f4654103ea45ac'
c.GitLabOAuthenticator.gitlab_host = 'https://www.gitlab.example.com'
c.JupyterHub.port = 443
c.JupyterHub.ssl_key = '/etc/jupyterhub/ssl/server.key'
c.JupyterHub.ssl_cert = '/etc/jupyterhub/ssl/server.crt'
c.Authenticator.admin_users = {'admin'}
c.PAMAuthenticator.admin_groups = {'masterG'}
New contributor
최지영 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.