Histórico de mensagens sobre credentials

EXIBINDO CONVERSAS RECENTES:

Texto: credentials
# pix
Avatar discord do usuario josneidrosdek

josneidrosdek

Ver Respostas

ae consegui passar mas agora gerou isso

{
"name": "erro_comunicacao",
"title": {
"error": "invalid_client",
"error_description": "Invalid or inactive credentials"
}
}

tem haver com alguma configuração da aplicação?

# devs
Avatar discord do usuario calhau9644

calhau9644

Ver Respostas

Boa tarde pessoal,

Estou tentando fazer uma chamada Post no endpoint https://pix-h.api.efipay.com.br/oauth/token pelo INSOMNIA.

Ja configurei o certificado PFX or PKCS12.

Ja adicionei no body da requisicao o

{
"grant_type": "client_credentials"
}

E ja adicionei tambem no Auth Basic o Username = ClientID e Password = Client_SECRET

Porem estou tendo o erro abaixo.

{
"error": "invalid_client",
"error_description": "Invalid or inactive credentials"
}

Alguem poderia me ajudar o que posso esta fazendo errado?

# pix
Avatar discord do usuario pedroigor1391

pedroigor1391

Ver Respostas

Bom dia, ao tentar fazer autenticação no postman me retorna o seguinte erro:

{
"error": "invalid_client",
"error_description": "Invalid or inactive credentials"
}

# dúvidas
Avatar discord do usuario joaolucas_efi

joaolucas_efi

Ver Respostas

@luizfeleal existem algumas falha em como você montou a requisição, segue um exemplo de como fazer a autenticação:

php
//Desenvolvido pela Consultoria Técnica da Efí
$config = [
"certificado" => "./certificado.pem",
"client_id" => "YOUR-CLIENT-ID",
"client_secret" => "YOUR-CLIENT-SECRET"
];
$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://pix-h.api.efipay.com.br/oauth/token", // Rota base, homologação ou produção
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": "client_credentials"}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

echo "
";
echo $response;
echo "
";
?>

# dúvidas
Avatar discord do usuario luizfeleal

luizfeleal

Ver Respostas

$credenciaisBase64 = base64_encode($cliente_id . ":" . $client_secret);

$url = env('URL_EFI') . "/oauth/token";

// Inicializa a sessão cURL
$ch = curl_init();


curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); // Verifica o certificado do servidor
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); // Verifica o host do certificado
curl_setopt($ch, CURLOPT_SSLCERT, $certificado); // Define o certificado a ser usado


// Adiciona os dados do cliente como autenticação básica
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
"Authorization: Basic " . $credenciaisBase64

]);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'grant_type' => 'client_credentials',
]));

// Executa a requisição e obtém a resposta
$resposta = curl_exec($ch);

# pix
Avatar discord do usuario aguiar.dev

aguiar.dev

py
from efipay import EfiPay
from dotenv import dotenv_values
import os

env = dotenv_values(".env")

class EfiPayImpl():

def __init__(self) -> None:
credentials = {
"client_id": env["EFI_BANK_CLIENT_ID"],
"client_secret": env["EFI_BANK_CLIENT_SECRET"],
"sandbox": env["EFI_BANK_SANDBOX"],
"certificate": f"{os.getcwd()}/{env["EFI_BANK_CERTIFICATE"]}"
}
self.api = EfiPay(credentials)
um exemplo da implementação que fiz usando py. Ali em certificate eu pego a raiz do meu projeto e passo a variavel do .env pra ele saber qual arquivo devo usar, se é homol ou prod

# pix
Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

$config = [
"certificado" => "./certificados/homologacao-certificado_cert.pem",
"client_id" => "???",
"client_secret" => "???"
];

$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => 'https://pix-h.api.efipay.com.br/oauth/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": "client_credentials"
}',
CURLOPT_SSLCERT => $config["certificado"],
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

if(curl_errno($curl)) {
echo 'Erro no cURL: ' . curl_error($curl);
} else {
echo $response;
}

# pix
Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

eu enviaria as credenciais novamente?
CURLOPT_POSTFIELDS =>'{
"grant_type": "client_credentials",
"client_id": "' . CLIENT_ID . '",
"client_secret": "' . CLIENT_SECRET . '"
}',

# pix
Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

{
"grant_type": "client_credentials"
}

# pix
Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

Guilherme, o que é client_credentials?

# pix
Avatar discord do usuario rodrigo_90439

rodrigo_90439

Ver Respostas

Tudo bem Guilherme.
Eu gostaria de utilizar o CURL mesmo, não quero utilizar o SDK em minha aplicação, tem como me ajudar?
$config = [
"certificado" => "certificado.pem",
"client_id" => "Client_Id???",
"client_secret" => "Client_Secret_???"
];

$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);

$curl = curl_init();

curl_setopt_array($curl, array(
//CURLOPT_URL => "https://pix-h.api.efipay.com.br/oauth/token",
CURLOPT_URL => "https://pagarcontas.api.efipay.com.br/v1/oauth/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": "client_credentials"}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

echo "

";
echo $response;
echo "
";

# pix
Avatar discord do usuario aguiar.dev

aguiar.dev

But I believe you don't need to change this class. The code I sent above solved it for me. My implementation:

py
from efipay import EfiPay
from dotenv import dotenv_values
import os

env = dotenv_values(".env")

class EfiPayImpl():

def __init__(self) -> None:
credentials = {
"client_id": env["EFI_BANK_CLIENT_ID"],
"client_secret": env["EFI_BANK_CLIENT_SECRET"],
"sandbox": env["EFI_BANK_SANDBOX"],
"certificate": f"{os.getcwd()}/{env["EFI_BANK_CERTIFICATE"]}"
}
self.api = EfiPay(credentials)

# pix
Avatar discord do usuario stoliarskiykostiantyn

stoliarskiykostiantyn

Hi everyone! Could someone help me please! I'm trying to implement EfiPay to send payment to pix with such code from python sdk from github repo https://github.com/efipay/sdk-python-apis-efi

Code looks like this now:

class EfiClient:
EFI_FT_PIX_KEY: str
EFI_FT_PIX_WEBHOOK_URL: str
efi: EfiPay
creds: s.EfiCredentials

def configure(self, config: BaseConfig):
# Notion: Sandbox = False on prod machine
self.creds = s.EfiCredentials(
client_id=config.EFI_CLIENT_ID,
client_secret=config.EFI_CLIENT_SECRET,
sandbox=config.EFI_IS_SANDBOX,
certificate=config.EFI_CERTIFICATE,
)

self.efi = EfiPay(self.creds.model_dump())
self.EFI_FT_PIX_KEY = config.EFI_FT_PIX_KEY
self.EFI_FT_PIX_WEBHOOK_URL = config.EFI_FT_PIX_WEBHOOK_URL

And the toruble is that efipay class doesn't acceprt certificates, support told me to chage base_url BUT there no way to do it! Help please) Would be very grateful!

# pix
Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

400
webhook_invalido
A autenticação de TLS mútuo não está configurada na URL informada
{
"Server": [
"nginx"
],
"Date": [
"Tue, 06 Aug 2024 20:01:54 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"111"
],
"Connection": [
"keep-alive"
],
"x-request-id": [
"aeaebb97-0acd-4c9c-a641-1bbfbe59461b"
],
"Vary": [
"Origin"
],
"Access-Control-Allow-Credentials": [
"true"
],
"ETag": [
"W/\"6f-u8LmFRZhTY5OErn2m2iNSr2g7AI\""
]
}


alguém consegue me dar uma base de como fuciona o código de recebimento da url? li a documentação e não estou conseguindo resolver isso

# pix
Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

me retornou o seguinte erro:


400
json_invalido
Parâmetro ".headers['x-skip-mtls-checking']", deve ser igual a um dos valores predefinidos
{
"Server": [
"nginx"
],
"Date": [
"Tue, 06 Aug 2024 18:59:18 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"241"
],
"Connection": [
"keep-alive"
],
"x-request-id": [
"xxxx"
],
"Vary": [
"Origin"
],
"Access-Control-Allow-Credentials": [
"true"
],
"ETag": [
"xxx""
]
}

# pix
Avatar discord do usuario felipenunes0714

felipenunes0714


/
Detailed endpoint documentation
https://dev.efipay.com.br/docs/api-pix/webhooks#configurar-o-webhook-pix
/

$autoload = realpath(__DIR__ . "../../../../../../../vendor/autoload.php");
if (!file_exists($autoload)) {
die("Autoload file not found or on path $autoload.");
}
require_once $autoload;

use Efi\Exception\EfiException;
use Efi\EfiPay;

$optionsFile = __DIR__ . "/../../credentials/options.php";
if (!file_exists($optionsFile)) {
die("Options file not found or on path $options.");
}
$options = include $optionsFile;

$options["headers"] = [
"x-skip-mtls-checking" => false
];

$params = [
"chave" => ""
];

$body = [
"webhookUrl" => ""
];


try {
$api = new EfiPay($options);
$response = $api->pixConfigWebhook($params, $body);

if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("

" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
print_r("
" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
} else {
print_r("
" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (EfiException $e) {
print_r($e->code . "
");
print_r($e->error . "
");
print_r($e->errorDescription) . "
";
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("
" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (Exception $e) {
print_r($e->getMessage());
}

# pix
Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas


/
Detailed endpoint documentation
https://dev.efipay.com.br/docs/api-pix/webhooks#configurar-o-webhook-pix
/

$autoload = realpath(__DIR__ . "/../../../vendor/autoload.php");
if (!file_exists($autoload)) {
die("Autoload file not found or on path $autoload.");
}
require_once $autoload;

use Efi\Exception\EfiException;
use Efi\EfiPay;

$optionsFile = __DIR__ . "/../../credentials/options.php";
if (!file_exists($optionsFile)) {
die("Options file not found or on path $options.");
}
$options = include $optionsFile;

$options["headers"] = [
"x-skip-mtls-checking" => false
];

$params = [
"chave" => "12345"
];

$body = [
"webhookUrl" => "www.meulink.com"
];

try {
$api = new EfiPay($options);
$response = $api->pixConfigWebhook($params, $body);

if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("

" . json_encode($response->body, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
print_r("
" . json_encode($response->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
} else {
print_r("
" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (EfiException $e) {
print_r($e->code . "
");
print_r($e->error . "
");
print_r($e->errorDescription) . "
";
if (isset($options["responseHeaders"]) && $options["responseHeaders"]) {
print_r("
" . json_encode($e->headers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "
");
}
} catch (Exception $e) {
print_r($e->getMessage());
}

# pix
Avatar discord do usuario gustavojr5502

gustavojr5502

Ola boa tarde ! Estou com problema na chamada do PixCreateImmediateCharge o erro do retorno é esse: "Could not authenticate. Please make sure you are using correct credentials and if you are using then in the correct environment.com"

# pix
Avatar discord do usuario felipenunes0714

felipenunes0714

Ver Respostas

$config = [
"certificado" => "./producao.pem",
"client_id" => "",
"client_secret" => ""
];


$autorizacao = base64_encode($config["client_id"] . ":" . $config["client_secret"]);

$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://pix-h.api.efipay.com.br/oauth/token", // Rota base, homologação ou produção
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": "client_credentials"}',
CURLOPT_SSLCERT => $config["certificado"], // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $autorizacao",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

echo "

";
echo $response;
echo "
";
?>

eu estou chamando essa chamada simples da documentação, e ela me retorna a pagina em branco ao invés de retornar o token