Getting Failed to check authorization: invalid_client

Bug description

I am launching SingleNotebook server with Jupyterhub on Kubernetes. After launching the user server while redirecting with oauth_callback am getting 500 error saying “Failed to check authorization: invalid_client”

Expected behaviour

After authentication it should load single user notebook server page.

Actual behaviour

Getting 500 error saying “Failed to check authorization: invalid_client”

Configuration file
c.JupyterHub.spawner_class = ‘kubespawner.KubeSpawner’
c.KubeSpawner.cmd = [“start.sh”, “–SingleUserNotebookApp.default_url=/lab”]
c.Spawner.http_timeout = 1800
c.Spawner.start_timeout = 1800

c.KubeSpawner.storage_capacity = “300M”
c.KubeSpawner.delete_pvc = False
c.KubeSpawner.pvc_name_template = ‘claim-{username}–{servername}’
c.KubeSpawner.storage_pvc_ensure = True
c.KubeSpawner.working_dir = “/home/admin”
c.KubeSpawner.cpu_guarantee = 0.1
c.KubeSpawner.mem_guarantee = “0.5G”
c.KubeSpawner.cpu_limit = 2
c.KubeSpawner.mem_limit = “4G”
c.KubeSpawner.namespace = “jupyterhub-qa”
c.KubeSpawner.image_pull_policy=‘Always’

c.KubeSpawner.image = ‘artifactorycn.suhas.com:17014/product/pyspark-jupyterhub_build:0.1-2

c.KubeSpawner.environment.update({
“HADOOP_CONF_DIR”: “/etc/hadoop/conf”,
“SPARK_CONF_DIR”: “/home/admin/conf”,
“PYSPARK_PYTHON”: “/usr/local/bin/python3.9”,
“PYSPARK_DRIVER_PYTHON”: “/usr/local/bin/python3.9”
})
c.KubeSpawner.volume_mounts = [{
“name”: “get-hadoop-conf”,
“mountPath”: “/scripts/get_hadoop_conf.sh”,
“subPath”: “get_hadoop_conf.sh”
},{
“name”: “clean-hive-config”,
“mountPath”: “/scripts/clean_hive_config.py”,
“subPath”: “clean_hive_config.py”
},{
“name”: “claim-{username}–{servername}”,
“mountPath”: “/home/admin”,
“subPath”: “value”
},{
“name”: “spark-conf”,
“mountPath”: “/tmp/spark-defaults.conf”,
“subPath”: “spark-defaults.conf”
},{
“name”: “pyspark-init-configmap”,
“mountPath”: “/scripts/pyspark-init.sh”,
“subPath”: “pyspark-init.sh”
}]

c.KubeSpawner.volumes = [{
“name”: “claim-{username}–{servername}”,
“persistentVolumeClaim”: {
“claimName”: “claim-{username}–{servername}”
}
},{
“name”: “get-hadoop-conf”,
“configMap”: {
“name”: “get-hadoop-conf”,
“defaultMode”: 0o0777
}
},{
“name”: “clean-hive-config”,
“configMap”: {
“name”: “clean-hive-config”,
“defaultMode”: 0o0777
}
},{
“name”: “spark-conf”,
“configMap”: {
“name”: “spark-conf”,
“defaultMode”: 0o0777
}
},{
“name”: “pyspark-init-configmap”,
“configMap”: {
“name”: “pyspark-init-configmap”,
“defaultMode”: 0o0777
}
}
]
c.KubeSpawner.extra_labels = {
“username”: “{username}”,
“spark”: “{username}-driver”
}
c.KubeSpawner.service_account = “jupyter-hub”
c.JupyterHub.authenticator_class = “jupyterhub.auth.DummyAuthenticator”
c.Authenticator.whitelist = [‘user’]
c.DummyAuthenticator.password = “useruser”
c.KubeSpawner.extra_container_config = {
“ports”: [
{
“name”: “http”,
“containerPort”: 8080,
“protocol”: “TCP”
},
{
“name”: “blockmanager”,
“containerPort”: 7777,
“protocol”: “TCP”
},
{
“name”: “driver”,
“containerPort”: 2222,
“protocol”: “TCP”
}
],
“securityContext”: {
“runAsUser”: 1000
}
}
c.KubeSpawner.lifecycle_hooks = {
“postStart”: {
“exec”: {
“command”: ["/bin/bash", “-c”, “/scripts/pyspark-init.sh”]
}
}
}
c.KubeSpawner.extra_pod_config = {
“hostNetwork”: True
}

Logs

[D 2022-01-31 12:28:12.044 SingleUserNotebookApp auth:836] Redirecting to login url: /hub/api/oauth2/authorize?client_id=jupyterhub-user-nikolay&redirect_uri=%2Fuser%2Fnikolay%2Foauth_callback&response_type=code&state=eyJ1dWlkIjogImYxNWE3Y2VjNTUyNDQ0ZTJhMjc1ZDEwZGQ5M2VlZTIyIiwgIm5leHRfdXJsIjogIi91c2VyL25pa29sYXkvbGFiPyJ9
[I 2022-01-31 12:28:12.045 SingleUserNotebookApp log:181] 302 GET /user/nikolay/lab? → /hub/api/oauth2/authorize?client_id=jupyterhub-user-nikolay&redirect_uri=%2Fuser%2Fnikolay%2Foauth_callback&response_type=code&state=[secret] (@192.168.0.18) 3.72ms
[D 2022-01-31 12:28:12.838 SingleUserNotebookApp auth:505] No user identified
[W 2022-01-31 12:28:12.863 SingleUserNotebookApp auth:369] Failed to check authorization: [401] Unauthorized
[W 2022-01-31 12:28:12.863 SingleUserNotebookApp auth:372] {“error”: “invalid_client”}
[W 2022-01-31 12:28:12.863 SingleUserNotebookApp web:1787] 500 GET /user/nikolay/oauth_callback?code=NTreocWmFXzSk7ar24ZK7OzTjdaSfE&state=eyJ1dWlkIjogImYxNWE3Y2VjNTUyNDQ0ZTJhMjc1ZDEwZGQ5M2VlZTIyIiwgIm5leHRfdXJsIjogIi91c2VyL25pa29sYXkvbGFiPyJ9 (192.168.0.18): Failed to check authorization: invalid_client

More Info if required: Getting "Failed to check authorization: invalid_client" · Issue #3783 · jupyterhub/jupyterhub · GitHub

Hi! Can you turn on debug logging, and show us the logs for the hub and singleuser servers?