For Workes & Pages, what is the name of the domain?
achecarro.com.br
What is the error number?
10000
What is the error message?
Authentication Error
What is the issue or error you’re encountering
I’m currently developing a automated php script to generate SSL certificates to our users domains, but when I try to create a custom hostname via the API, I can’t call the POST route for it, all I get is a Error 10000: Authentication Error. I call can the GET route for Custom Hostnames, even though I configured the token to have the permission to write and read
What steps have you taken to resolve the issue?
I’ve tried generating new tokens with different permissions but it changed nothing when trying to call the API.
What are the steps to reproduce the issue?
Generate a new token with SSL and Custom Hostnames write and read permissions and call the route https://api.cloudflare.com/client/v4/zones/{ZONE_ID}/custom_hostnames with a POST method through php CURL, sending the bearer token in the request headers and the body containg the hostname, ssl method and type.
Code example:
`
private $headers = Array (
‘Authorization: Bearer {YOUR_TOKEN}’,
);
function generateCloudflareSSLCertificate($hostname, $sslMethod = 'txt', $sslType = 'dv') {
$zoneId = {YOUR_ZONE_ID};
$postFields = Array(
'hostname' => $hostname,
'ssl' => Array(
'method' => $sslMethod,
'type' => $sslType
),
);
if($json = $this->curlConnect($this->url.'/zones/'.$zoneId.'/custom_hostnames', null, null, $this->headers)) {
$response = json_decode($json, true);
var_dump($response);
}
if($json = $this->curlConnect($this->url.'/zones/'.$zoneId.'/custom_hostnames', null, $postFields, $this->headers)) {
$response = json_decode($json, true);
var_dump($response);
}
}
`
The first var_dump should work as intended as it’s a GET request, but the second API call shouldn’t.