def google_api_post(email, url, post_data, authorized=True):
    # TODO: Make this a lot less ugly. especially the 401 handling
    headers = dict()
    if authorized is True:
        headers.update(dict(
            Authorization="Bearer %s" % get_google_access_token(email),
        ))
    r = requests.post(url, headers=headers, data=post_data)
    if r.status_code == 401:
        refresh_authorization(email)
        r = requests.post(url, headers=headers, data=post_data)
    if r.status_code == 200:
        try:
            return r.json()
        except __HOLE__:
            return r.text
dataset/ETHPy150Open coddingtonbear/django-mailbox/django_mailbox/google_utils.py/google_api_post