Add KeyError check

This commit is contained in:
Micke Nordin 2024-01-13 15:52:01 +01:00
parent 1226cbbf11
commit 913980a027
Signed by untrusted user: Micke
GPG key ID: 0DA0A7A5708FE257

View file

@ -30,6 +30,7 @@ hub:
spawner.environment['NEXTCLOUD_ACCESS_TOKEN'] = access_token
async def refresh_user(self, user, handler=None):
try:
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']
@ -40,6 +41,8 @@ hub:
return False
print(f'Time is: {now}, token expires: {expires}')
return True
except KeyError:
return False
c.JupyterHub.authenticator_class = NextcloudOAuthenticator
c.NextcloudOAuthenticator.client_id = os.environ['NEXTCLOUD_CLIENT_ID']