From 92dd24450dc3795b25bfbcbc767d6e52498d92c7 Mon Sep 17 00:00:00 2001 From: codl Date: Sun, 10 Sep 2017 12:23:54 +0200 Subject: fix exception in log_in, by accepting json dates as timestamps when requesting a bearer token, mastodon (more specifically doorkeeper) returns an object with a created_at attribute which is a plain timestamp unlike in most of mastodon's api: { "access_token": "hunter2", "token_type": "bearer", "scope": "read write", "created_at": 1504824250, } --- mastodon/Mastodon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mastodon/Mastodon.py') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index ed8901c..d427444 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -973,7 +973,10 @@ class Mastodon: for k, v in json_object.items(): if k in known_date_fields: try: - json_object[k] = dateutil.parser.parse(v) + if isinstance(v, int): + json_object[k] = datetime.datetime.fromtimestamp(v, pytz.utc) + else: + json_object[k] = dateutil.parser.parse(v) except: raise MastodonAPIError('Encountered invalid date.') return json_object -- cgit v1.2.3