Skip to content

Instantly share code, notes, and snippets.

@yuvipanda
Created November 19, 2019 21:28
Show Gist options
  • Save yuvipanda/abb9fc0ac87d78e7f95552cca5fe16e4 to your computer and use it in GitHub Desktop.
Save yuvipanda/abb9fc0ac87d78e7f95552cca5fe16e4 to your computer and use it in GitHub Desktop.
from oauthenticator.generic import GenericOAuthenticator
class CustomAuthenticator(GenericOAuthenticator):
async def authenticate(self, handler, data=None):
resp = await super().authenticate(handler, data)
# resp is a dict mentioned here: https://github.com/jupyterhub/oauthenticator/blob/master/oauthenticator/generic.py#L163
# modify it as you wish, set username key
modified_resp = resp.copy()
modified_resp['username'] = resp['auth_state']['oauth_resp']['attrib']['email']
return modified_resp
hub:
extraConfig:
01-custom-auth: |
<copy-the generic.py here>
c.JupyterHub.authenticator_class = CustomAuthenticator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment