Histórico de mensagens sobre credentials

EXIBINDO CONVERSAS RECENTES:

Texto: credentials
# pix
Avatar discord do usuario alexmelloprovider1302

alexmelloprovider1302

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

# pix
Avatar discord do usuario Krisdhya

Krisdhya

Ver Respostas

Boa tarde,
parece que esta errado a parte de credentials colocado na documentação da gerencianet na aba "C#",
assim estou com dificuldade para gerar o token

# sugestões
Avatar discord do usuario rubenskuhl

rubenskuhl

Mas algo que o BACEN reconhece é que a API como está é um pouco trabalhosa para intermediários que não os correntistas, e eles parecem abertos a ter uma interface para intermediários usando Authorization Code Flow ao invés de Client Credentials Flow, entre outras diferenças.

# pix
Avatar discord do usuario rafaelvolpato

rafaelvolpato

import feign.Body;
import feign.Headers;
import feign.Param;
import feign.RequestLine;

public interface PixAPI {

@Headers({"x-client-cert-pem: {{X-Certificate-Pem}}", "Authorization: {authorization}", "Content-type: application/json"})
@RequestLine("POST /oauth/token")
@Body("{\"grant_type\":\"client_credentials\"}")
OAuthResponseDTO oauthToken(/ String cert, /@Param("authorization") String authorization);

@Headers({/ "x-client-cert-pem: {cert}", / "Authorization: {oauthToken}", "x-mtls-bypass: 1"})
@RequestLine("PUT /v2/webhook/{accountKey}")
@Body("%7B\"webhookUrl\": \"{webhookUrl}\"%7D")
PixWebhookResponseDTO configureWebhook(@Param("oauthToken") String oauthToken, @Param("webhookUrl") String webhookUrl, @Param("accountKey") String accountKey);

@Headers({/ "x-client-cert-pem: {cert}", / "Authorization: {oauthToken}", "x-mtls-bypass: 1"})
@RequestLine("DELETE /v2/webhook/{accountKey}")
void removeWebhook(@Param("oauthToken") String oauthToken, @Param("accountKey") String accountKey);

}

# pix
Avatar discord do usuario oleoessencial

oleoessencial


$curl = curl_init();

curl_setopt_array($curl, array(
CURLOPT_URL => "https://api-pix-h.gerencianet.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 =>"{\r\n \"grant_type\": \"client_credentials\"\r\n}",
CURLOPT_HTTPHEADER => array(
"x-client-cert-pem: {{X-Certificate-Pem}}",
"Authorization: Basic Q3334f34f34f3g5355gh56hg5w6h457wg457w54w56h7w56f5f6wNzVmZGQxNGU2MDMxMjlhNTMw",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

# pix
Avatar discord do usuario amandamiranda2492

amandamiranda2492

Ver Respostas

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

# pix
Avatar discord do usuario oleoessencial

oleoessencial

Ver Respostas

{
"grant_type": "client_credentials"
}

# pix
Avatar discord do usuario guilherme_efi

guilherme_efi

Ver Respostas

Verifique se no body da requisição está com essa informação:
{
"grant_type": "client_credentials"
}

# pix
Avatar discord do usuario paulacastro224023

paulacastro224023

O erro que recebo é Invalid or inactive credentials, estou usando o ambiente do postman mesmo com a chave em p12, nele há a necessidade de converter para pem ?

# pix
Avatar discord do usuario rodolfo.santos8069

rodolfo.santos8069

Ver Respostas

Muda para:

CURLOPT_POSTFIELDS => json_encode(array('grant_type' => 'client_credentials')),

# pix
Avatar discord do usuario lorenacastro

lorenacastro

Ver Respostas

function auth() {
$file = file_get_contents("./config.json");
$config = json_decode($file, true);
$environment = ($config["sandbox"] === true) ? "development" : "production";

$certfile = $config[$environment]["certificate_name"];

$curl = curl_init();

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

curl_setopt_array($curl, array(
CURLOPT_URL => $config[$environment]["pix_auth_url"], // Rota base, desenvolvimento 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 => $certfile, // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $authorization",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

echo "

";
echo $response;
echo "
";
}

# pix
Avatar discord do usuario lorenacastro

lorenacastro

usa assim CURLOPT_POSTFIELDS => '{"grant_type":"client_credentials"}',

# pix
Avatar discord do usuario oleoessencial

oleoessencial

Ver Respostas

olá, usei isso porem quando envio a erro no CURLOPT_POSTFIELDS => json_encode("{"grant_type": "client_credentials"}"),

# pix
Avatar discord do usuario jaoedson

jaoedson

Acho que o problema estava só aqui $arr = ['grant_type' => 'client_credentials']; que estava diferente do meu

# pix
Avatar discord do usuario lorenacastro

lorenacastro

eu fiz assim, para teste:

function auth() {
$ch = curl_init();

$requestURL = 'https://api-pix-h.gerencianet.com.br/oauth/token';
$cliendId = ''; //seu client id
$clientSecret = ''; //seu client secret
$authorization = base64_encode($cliendId . ":" . $clientSecret);
$certFile = ''; //o caminho do certificado
$arr = ['grant_type' => 'client_credentials'];
$headers = [];
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Basic ' . $authorization;

curl_setopt($ch, CURLOPT_URL, $requestURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($arr));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_SSLCERT, $certFile);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
$resposta = json_decode($result);

if (curl_errno($ch)) {
die('Erro: ' . curl_error($ch));
}

curl_close($ch);

return $resposta->access_token;
}

# pix
Avatar discord do usuario oleoessencial

oleoessencial

Ver Respostas

Estou tentando usar este exemplo , aonde eu pego o {"grant_type": "client_credentials"} ?
$file = file_get_contents("./config.json");
$config = json_decode($file, true);
$environment = ($config["sandbox"] === true) ? "development" : "production";

$certfile = "./certificate/" . $config[$environment]["certificate_name"];

$curl = curl_init();

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

curl_setopt_array($curl, array(
CURLOPT_URL => $config[$environment]["pix_auth_url"], // Rota base, desenvolvimento 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 => json_encode("{"grant_type": "client_credentials"}"),
CURLOPT_SSLCERT => $certfile, // Caminho do certificado
CURLOPT_SSLCERTPASSWD => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Basic $authorization",
"Content-Type: application/json"
),
));

$response = curl_exec($curl);

curl_close($curl);

echo "

";
echo $response;
echo "
";

# pix
Avatar discord do usuario oleoessencial

oleoessencial

> Boa tarde,
> O Vagner Moreira me enviou o certificado, client_id e client_secret por e-mail, e me indicou este grupo pra tirar dúvidas.
> Configurei o environment no postman conforme o vídeo
> Importei a collection GN-PIX-API.postman_collection.json
> Preenchi as credenciais em Athorization
> Mas ao dar send em {{gn-pix-api}}/oauth/token está retornando
> {"error":"invalid_client","error_description":"Invalid or inactive credentials"}
> O que eu poderia estar fazendo de errado?
<@!778694543151071235> da uma olhada neste vídeo =https://www.loom.com/share/9f9cf5b0a95643a092c41f001929b791

# pix
Avatar discord do usuario diogonox3254

diogonox3254

Ver Respostas

Boa tarde,
O Vagner Moreira me enviou o certificado, client_id e client_secret por e-mail, e me indicou este grupo pra tirar dúvidas.
Configurei o environment no postman conforme o vídeo
Importei a collection GN-PIX-API.postman_collection.json
Preenchi as credenciais em Athorization
Mas ao dar send em {{gn-pix-api}}/oauth/token está retornando
{"error":"invalid_client","error_description":"Invalid or inactive credentials"}
O que eu poderia estar fazendo de errado?

# pix
Avatar discord do usuario lorenacastro

lorenacastro

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

# pix
Avatar discord do usuario sady_efi

sady_efi

using System;
using System.Security.Cryptography.X509Certificates;
using RestSharp;
namespace pix
{
class Program
{
static void Main(string[] args)
{
X509Certificate2 uidCert = new X509Certificate2("./certificado.p12", "");
var client = new RestSharp.RestClient("https://api-pix-h.gerencianet.com.br/oauth/token");
client.ClientCertificates = new X509CertificateCollection() { uidCert };
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\r\n \"grant_type\": \"client_credentials\"\r\n}", ParameterType.RequestBody);
IRestResponse restResponse = client.Execute(request);
string response = restResponse.Content;
Console.WriteLine(response);
}
}
}