0
0
mirror of https://github.com/thegeeklab/corenetworks.git synced 2024-11-14 16:50:39 +00:00

add expires timestamp to the BasicAuth object

This commit is contained in:
Robert Kaussow 2020-05-12 13:17:12 +02:00
parent f2d705a994
commit 0bb59c7308
2 changed files with 7 additions and 4 deletions

View File

@ -1,2 +1,2 @@
* BUGFIX
* extend the workaround to ensure CNAME records could not mixed with other types using the same name
* ENHANCEMENT
* add `expires` timestamp to the BasicAuth object

View File

@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
"""Custom authenticators."""
import datetime
import json
from requests import ConnectionError
@ -19,7 +20,7 @@ class CoreNetworksBasicAuth(AuthBase):
self.user = user
self.password = password
self.endpoint = endpoint
self.token = self._login()
self.token, self.expires = self._login()
def __eq__(self, other): # noqa
return all([
@ -60,8 +61,10 @@ class CoreNetworksBasicAuth(AuthBase):
raise
response = handle.json()
token = response["token"]
expires = datetime.datetime.now() + datetime.timedelta(seconds=response["expires"])
return response["token"]
return token, expires
class CoreNetworksTokenAuth(AuthBase):