From 1ce4654673004509185f3a83d6e1da15cd030c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Sat, 15 Apr 2017 13:23:11 +0200 Subject: [PATCH] Autodetect timestamp format in Blender ID token expiry. The new Blender ID uses a different timestamp format than the old one. We can alter Blender ID, but using the ISO 8601 is a good idea anyway. --- pillar/api/blender_id.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pillar/api/blender_id.py b/pillar/api/blender_id.py index 3fcc0ebb..ba5bac9d 100644 --- a/pillar/api/blender_id.py +++ b/pillar/api/blender_id.py @@ -200,8 +200,11 @@ def _compute_token_expiry(token_expires_string): the token. """ - date_format = current_app.config['RFC1123_DATE_FORMAT'] - blid_expiry = datetime.datetime.strptime(token_expires_string, date_format) + # requirement is called python-dateutil, so PyCharm doesn't find it. + # noinspection PyPackageRequirements + from dateutil import parser + + blid_expiry = parser.parse(token_expires_string) blid_expiry = blid_expiry.replace(tzinfo=tz_util.utc) our_expiry = datetime.datetime.now(tz=tz_util.utc) + datetime.timedelta(hours=1)