auth_server.py 文件源码

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

项目:cbas 作者: ImmobilienScout24 项目源码 文件源码
def obtain_access_token(config, password):
    info("Will now attempt to obtain an JWT...")
    auth_request_data = {'client_id': 'jumpauth',
                         'username': config.username,
                         'password': password,
                         'grant_type': 'password'}
    auth_url = get_auth_url(config)
    auth_response = requests.post(auth_url, auth_request_data)

    if auth_response.status_code not in [200, 201]:
        log.info("Authentication failed: {0}".
                 format(auth_response.json().get("error")))
        auth_response.raise_for_status()
    else:
        log.info("Authentication OK!")

    # TODO bail out if there was no access token in the answer
    access_token = auth_response.json()['access_token']
    info("Access token was received.")
    verbose("Access token is:\n'{0}'".format(access_token))
    return access_token
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号