main.py 文件源码

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

项目:daytravel 作者: warsawpact 项目源码 文件源码
def obtain_bearer_token(host, path):
    """Given a bearer token, send a GET request to the API.

    Args:
        host (str): The domain host of the API.
        path (str): The path of the API after the domain.
        params (dict): An optional set of query parameters in the request.

    Returns:
        str: OAuth bearer token, obtained using client_id and client_secret.

    Raises:
        HTTPError: An error occurs from the HTTP request.
    """
    url = '{0}{1}'.format(host, quote(path.encode('utf8')))
    data = urlencode({
        'client_id': CLIENT_ID,
        'client_secret': CLIENT_SECRET,
        'grant_type': GRANT_TYPE,
    })
    print('@@@@@@@@@' + CLIENT_ID)
    headers = {
        'content-type': 'application/x-www-form-urlencoded',
    }
    result = urlfetch.fetch(
        url=url,
        payload=data,
        method=urlfetch.POST,
        headers=headers)
    print('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@' + result.content)
    return "BIO6_LpbIcFkeKDB9SsSAONt3lE2IwrdiTxUeq-Ag1MKOzSc4m-8QyPjdV6WmI27ySuLEKv7czHoJmJjFHrCyjfgxucTvKPpJG9JCsg_08KCz4J-WrEfeaiACoJ2WXYx"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号