def validateAuthCode(code, redirect_uri, client_id, state=None, validationEndpoint='https://indieauth.com/auth', headers={}):
    """Call authorization endpoint to validate given auth code.

    :param code: the auth code to validate
    :param redirect_uri: redirect_uri for the given auth code
    :param client_id: where to find the auth endpoint for the given auth code
    :param state: state for the given auth code
    :param validationEndpoint: URL to make the validation request at
    :param headers: optional headers to send with any request
    :rtype: True if auth code is valid
    """
    payload = {'code':         code,
               'redirect_uri': redirect_uri,
               'client_id':    client_id,
              }
    if state is not None:
        payload['state'] = state

    authURL = None
    authEndpoints = discoverAuthEndpoints(client_id, headers=headers)
    for url in authEndpoints['authorization_endpoint']:
        authURL = url
        break
    if authURL is not None:
        validationEndpoint = ParseResult(authURL.scheme, authURL.netloc, authURL.path, '', '', '').geturl()

    r = requests.post(validationEndpoint, verify=True, data=payload, headers=headers)
    result = { 'status':  r.status_code,
               'headers': r.headers
             }
    if 'charset' in r.headers.get('content-type', ''):
        result['content'] = r.text
    else:
        result['content'] = r.content
    if r.status_code == requests.codes.ok:
        result['response'] = parse_qs(result['content'])

    return result
Call authorization endpoint to validate given auth code.

    :param code: the auth code to validate
    :param redirect_uri: redirect_uri for the given auth code
    :param client_id: where to find the auth endpoint for the given auth code
    :param state: state for the given auth code
    :param validationEndpoint: URL to make the validation request at
    :param headers: optional headers to send with any request
    :rtype: True if auth code is valid