Erro ao Trocar um authorization code por um access token

Comunidade

Ask a Question
Back to All

Erro ao Trocar um authorization code por um access token

Boa tarde,

Estou recebendo retorno 500 ao utilizar a chamada da API via PHP cURL em sandbox, mas ao utilizar os mesmos dados no postman retorna 200 com o raw esperado.

Segue exemplo da requisição que estou usando:

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://sandbox.api.pagseguro.com/oauth2/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"grant_type": "authorization_code",
"code": "802d26bdc1e643b8b4f49ef153979871",
"redirect_uri": "https://glnovo.ds.talto.com.br/?_view=site.cliente_pagseguro&_action=postNew",
}',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer B8CBB20C083148B38C830A69487D0B0D',
'Content-Type: application/json',
'X_CLIENT_ID: 57d06788-851e-4876-8004-af3fa0ea9195',
'X_CLIENT_SECRET: c5bc76f8-0be3-4a3a-b44b-6fcff8006f92'
),
));

E o retorno:
[content_type] => application/json
[http_code] => 500
[header_size] => 609
[request_size] => 599
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 0.299691
[namelookup_time] => 0.243139
[connect_time] => 0.245893
[pretransfer_time] => 0.265512
[size_upload] => 271
[size_download] => 0
[speed_download] => 0
[speed_upload] => 906
[download_content_length] => 0
[upload_content_length] => 271
[starttransfer_time] => 0.299668
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 13.225.63.84
[certinfo] => Array
(
)

[primary_port] => 443
[local_ip] => xxx.223.179.xxx
[local_port] => 44056