Comunidade

Ask a Question
Back to All

Erro ao obter o access token no ambiente de sandbox do PagSeguro...

Ao tentar obter o access token ["grant_type" => "challenge"]no ambiente de sandbox do PagSeguro, estou recebendo o seguinte erro: "not_found_url" (código 41013). No entanto, se eu trocar para o ambiente de produção e utilizar o token de produção, consigo obter o access token ["grant_type" => "challenge"] resolver o problema, gerar e baixar os certificados normalmente. Gostaria de saber como posso resolver esse problema e obter os certificados no ambiente de sandbox para realizar a homologação corretamente.

Descrição do problema: Estou utilizando a seguinte configuração e código para obter o certificado no ambiente de sandbox do PagSeguro:

Authorization Bearer : [Authorization]
client_id: [client_id]
client_secret: [client_secret]

$curl = curl_init();

$data = array(
'grant_type' => 'challenge',
'scope' => 'certificate.create'
);

curl_setopt_array($curl, [
CURLOPT_URL => 'https://sandbox.api.pagseguro.com/oauth2/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode($data),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $authorization,
'X_CLIENT_ID' => $client_id,
'X_CLIENT_SECRET' => $client_secret,
'Accept: application/json',
'Content-Type: application/json'
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

dd([
'error' => curl_error($curl),
'response' => $response
]);

array(2) {
["error"]=>
string(0) ""
["response"]=>
string(67) "{"error_messages":[{"code":"41013","description":"not_found_url"}]}"
}

desde ja agradeço a atenção!