def auth():
"""
Authenticates the user using the url, application key,
email and the password.
@return: a `dict` object with the keys `token` and `minutos`,
from json returned from the API.
"""
global token
endpoint = '/signin'
url = settings.URL
key = settings.API_KEY
res = requests.post(
url + endpoint,
headers={
'date': date(),
'x-api-key': key,
},
json={
'email': settings.EMAIL,
'password': settings.PASSWORD
},
**settings.REQUEST_OPTIONS
)
try:
res = res.json()
token = res['token']
except Exception:
pass
return res
评论列表
文章目录