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,
}
This commit is contained in:
codl 2017-09-10 12:23:54 +02:00
pare 7ded08fd84
commit 92dd24450d
No se encontró ninguna clave conocida en la base de datos para esta firma
ID de clave GPG: 6CD7C8891ED1233A

Veure arxiu

@ -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