X-auth-email

api_key = "Global API Key"
email = "cloudflare id"
zone_id = "zone_id"

headers = {"X-Auth-Email" : email, "X-Auth-Key" : api_key}
json_data = {"type" : "A", "name" : request.form["url"], "content" : "ip", "ttl" : 1, "proxied" : True}

Hi
If I enter the email used to log in to cloudflare in x-auth-email, does it work?
I entered everything normally, but the error persists

{"success":false,"errors":[{"code":9106,"message":"Missing X-Auth-Key, X-Auth-Email or Authorization headers"}]}

Are you sure you’re actually sending the “headers” part? Is there a way to get a verbose response of what you’re actually sending?

api_key = ""
email = ""
zone_id = ""

headers = {"X-Auth-Email" : email, "X-Auth-Key" : api_key}
json_data = {"type" : "A", "name" : request.form["url"], "content" : "ip", "ttl" : 1, "proxied" : True}
try:
      res_data = requests.post(f"https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records", headers=headers, json=json_data).json()
    except:
          pass
    return "ok"

The code is entered as being transmitted as a “header”.
Is it correct to enter the email used to log in to cloudflare in X-Auth-Email?

Yes, your Global API Key has just the one email address – the one you log in with to see that API Key.

{"success":false,"errors":[{"code":9106,"message":"Missing X-Auth-Key, X-Auth-Email or Authorization headers"}]}

I’ve been angry with this problem for a week, and no matter how accurate information is entered, an error occurs. The server is creating a web using Python in aws. I’m asking for advice, as it’s not a problem I can solve alone. I want to know if my python code is wrong.

                            api_key = ""
                            email = ""
                            zone_id = ""

                            headers = {"X-Auth-Email" : email, "X-Auth-Key" : api_key}
                            json_data = {"type" : "A", "name" : request.form["url"], "content" : "ip", "ttl" : 1, "proxied" : True}
                            try:
                                res_data = requests.post(f"https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records", headers=headers, json=json_data).json()
                            except:
                                pass
                            return "ok"

Hi there,

I am unable to reproduce the issue on my end. Could you try printing the request headers to ensure X-Auth-Email and X-Auth-Key are actually being sent?

import requests


zone_id = 'cd7d068de3012345da9420df9514dad0'

headers = {
    'X-Auth-Email': '[email protected]',
    'X-Auth-Key': '1234567893feefc5f0q5000bfo0c38d90bbeb'
}

json = {
    'type': 'AAAA',
    'name': 'subdomain',
    'content': '100::',
    'proxied': True
}

response = requests.post(f'https://api.cloudflare.com/client/v4/zones/{zone_id}/dns_records', headers=headers, json=json)

print(response.json())

print(response.request.headers)

Hello Albert, thank you so much for your response. I struggled with this issue for a bit until I decided to see if others had run into similar issues. So the sample request included in the doc for python requests module(screenshot attached), makes it seem like you require either the auth-key or the auth-email, and not both. Even the doc itself, doesn’t state that both are required. Perhaps this should be reviewed to aid others in the future. Thanks.