'Authentication error using cloudflare api

I repeatedly received an authentication error just like this (not me) when using the Cloudflare api.

curl -X GET "https://api.cloudflare.com/client/v4/zones/<ZONEID>/dns_records?type=A&name=<DOMAIN>&content=127.0.0.1&proxied=undefined&page=1&per_page=20&order=type&direction=desc&match=all" \
 -H "X-Auth-Email: <EMAIL>" \
 -H "X-Auth-Key: <APITOKEN>" \
 -H "Content-Type: application/json"

 {“success”:false,“errors”:[{“code”:10000,“message”:“Authentication error”}]}

What am I doing wrong?



Solution 1:[1]

Apparently the only way that seems to work is to use the user token instead of the zone one.

curl -XPOST -H 'X-Auth-Key: TOKEN' -H 'X-auth-email: EMAIL' -H \"Content-type: application/json\" -d '{\"type\":\"CNAME\",\"name\":\"hi\",\"content\":\"example.com\",\"proxied\":true}' 'https://api.cloudflare.com/client/v4/ZONE_ID/dns_records'

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 cooprofessor