api.py 文件源码

python
阅读 55 收藏 0 点赞 0 评论 0

项目:strans-pyra 作者: teresinahc 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号