marafado88
CDCloudflare Developers
•Created by marafado88 on 1/16/2025 in #general-help
Unable to authenticate request through Cloudflare Python Module
I am following Cloudflare documentation for the first time to get DNS records inside of DNS Zones: https://developers.cloudflare.com/api/python/resources/dns/subresources/records/methods/list/
As a start I have installed cloudflare Python Module (4.0.0), but when I try to run that script given on Cloudflare API documentation, it gives me an error, and I really don’t know what can be, since I have been using ‘requests’ with cloudflare queries with an API Key that has real-only for all permissions (set on my account), and have been able to get data, but with that python module I am getting:
cloudflare.BadRequestError: Error code: 400 - {‘success’: False, ‘errors’: [{‘code’: 10001, ‘message’: ‘Unable to authenticate request’}]}
This is the code I am using:
from cloudflare import Cloudflare
ZONE_ID = ‘XXXX’
CLOUDFLARE_EMAIL = ‘XXXX’
CLOUDFLARE_API_KEY = ‘XXXX’
client = Cloudflare(
api_email=CLOUDFLARE_EMAIL
api_key=CLOUDFLARE_API_KEY
)
page = client.dns.records.list(
zone_id=ZONE_ID,
)
page = page.result[0]
print(page)
Have also tried with just user_service_key inside of client, taking into account that was using just an API KEY to auth before over the other method, but got the same error.
I am trying to use this python module because it will be a lot more easier for me to work with.
I am felling a bit lost here … anyone here know what can be? or had the same issue?
4 replies