"List Domains" Authentication error when using Api Token

Hi, when I try to list domains(Cloudflare API v4 Documentation), using the Api Token, I get “Authentication error” but when using the email and api key everything works as it should, everything else works fine when using Api Token, list domains is the only one causing problems. My question is, is there a way to list domains with the Api Token?

Note: The Api Token uses the “Read all resources” template.

You might have the API syntax incorrect. Can you post a screenshot of your request? It’s ok to black out the sensitive parts.

Am using Postman to test all this, this is the code snippet postman creates for “Api Token”

curl --location --request GET ‘https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_IDENTIFIER>/registrar/domains’ \

–header ‘Authorization: Bearer <API_TOKEN>’
Firing this of returns

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

Postman code snippet for “Email and Api Key”

curl --location --request GET ‘https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_IDENTIFIER>/registrar/domains’ \

–header ‘X-Auth-Email: EMAIL’ \

–header ‘X-Auth-Key: <GLOBAL_API_KEY>’

Firing this returns the response I need

Note: I’ve replaced the sensitive data with <ACCOUNT_IDENTIFIER>, <API_TOKEN>, EMAIL, <GLOBAL_API_KEY>

I’m surprised the GET works with the global key. According to the API docs, it’s supposed to be a POST.

Same thing happens when using the POST method with and without a body

At this point, I’d start fiddling with the token permissions. Get away from the predefined template which might not include Registrar features and start looking at individual permissions.

Will do, thank you for your help.

1 Like