Compare commits

..

2 commits

Author SHA1 Message Date
Micke Nordin fbc276d175
Add refresh user function 2024-01-13 15:30:57 +01:00
Micke Nordin 711c3b516b
Format 2024-01-13 15:30:12 +01:00

View file

@ -21,11 +21,19 @@ hub:
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.user_dict = {} self.user_dict = {}
def pre_spawn_start(self, user, spawner): def pre_spawn_start(self, user, spawner):
super().pre_spawn_start(user, spawner) super().pre_spawn_start(user, spawner)
access_token = self.user_dict[user.name]['access_token'] access_token = self.user_dict[user.name]['access_token']
# refresh_token = self.user_dict[user.name]['refresh_token']
spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token
async def refresh_user(self, user, handler=None):
access_token = self.user_dict[user.name]['access_token']
refresh_token = self.user_dict[user.name]['refresh_token']
token_response = self.user_dict[user.name]['token_response']
print(token_response)
return True
c.JupyterHub.authenticator_class = NextcloudOAuthenticator c.JupyterHub.authenticator_class = NextcloudOAuthenticator
c.NextcloudOAuthenticator.client_id = os.environ['NEXTCLOUD_CLIENT_ID'] c.NextcloudOAuthenticator.client_id = os.environ['NEXTCLOUD_CLIENT_ID']
c.NextcloudOAuthenticator.client_secret = os.environ['NEXTCLOUD_CLIENT_SECRET'] c.NextcloudOAuthenticator.client_secret = os.environ['NEXTCLOUD_CLIENT_SECRET']