-
Total de ítens
17 -
Registro em
-
Última visita
Community Answers
-
EduXml's post in Erro no status e envio NFce was marked as the answer
A solução para a consulta do status do serviço para NFCe foi trocando o certificado para um A1.
O outro certificado era um A1 na nuvem para NFe a consulta do status do serviço funciona.
-
EduXml's post in Rest carregar certificado was marked as the answer
Resolvido através do HTTP
Segue código abaixo
function ObterToken():integer;
var
HTTPClient: TIdHTTP;
SSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
url,json: string;
JsonStreamRetorno, JsonStreamEnvio: TStringStream;
retorno : integer;
begin
url := 'https://mtls-mp.hml.flagship.maas.link/auth/realms/Matera/protocol/openid-connect/token';
HTTPClient := TIdHTTP.Create(nil);
HTTPClient.Request.CharSet := 'utf-8';
HTTPClient.Request.Accept := '*/*';
HTTPClient.Request.AcceptEncoding := 'gzip, deflate, br';
HTTPClient.Request.CustomHeaders.Values['Content-Type'] := 'application/x-www-form-urlencoded';
HTTPClient.HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth];
HTTPClient.HandleRedirects := True;
json:= 'grant_type=client_credentials&client_id=teste&client_secret=123456789'; //aqui era o maior problema
JsonStreamEnvio := TStringStream.Create(utf8Encode(json));
JsonStreamRetorno := TStringStream.Create('');
SSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
try
SSLIOHandler.SSLOptions.Mode := sslmUnassigned;
SSLIOHandler.SSLOptions.CertFile := 'd:\matera\novo\certificate.pem';
SSLIOHandler.SSLOptions.KeyFile := 'd:\matera\novo\certificate.key';
SSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2];
HTTPClient.IOHandler := SSLIOHandler;
try
HTTPClient.Post(url, JsonStreamEnvio, JsonStreamRetorno);
except
retorno := HTTPClient.ResponseCode;
end;
retorno := HTTPClient.ResponseCode;
if retorno = 200 then
begin
JsonStreamRetorno.SaveToFile('d:\token.json');
end;
finally
HTTPClient.Free;
SSLIOHandler.Free;
end;
end;
Obrigado Pessoal.
-
EduXml's post in Obter token API via Synapse ou HTTP was marked as the answer
Resolvido
Segue código abaixo
function ObterToken():integer;
var
HTTPClient: TIdHTTP;
SSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
url,json: string;
JsonStreamRetorno, JsonStreamEnvio: TStringStream;
retorno : integer;
begin
url := 'https://mtls-mp.hml.flagship.maas.link/auth/realms/Matera/protocol/openid-connect/token';
HTTPClient := TIdHTTP.Create(nil);
HTTPClient.Request.CharSet := 'utf-8';
HTTPClient.Request.Accept := '*/*';
HTTPClient.Request.AcceptEncoding := 'gzip, deflate, br';
HTTPClient.Request.CustomHeaders.Values['Content-Type'] := 'application/x-www-form-urlencoded';
HTTPClient.HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth];
HTTPClient.HandleRedirects := True;
json:= 'grant_type=client_credentials&client_id=teste&client_secret=123456789'; //aqui era o maior problema
JsonStreamEnvio := TStringStream.Create(utf8Encode(json));
JsonStreamRetorno := TStringStream.Create('');
SSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
try
SSLIOHandler.SSLOptions.Mode := sslmUnassigned;
SSLIOHandler.SSLOptions.CertFile := 'd:\matera\novo\certificate.pem';
SSLIOHandler.SSLOptions.KeyFile := 'd:\matera\novo\certificate.key';
SSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2];
HTTPClient.IOHandler := SSLIOHandler;
try
HTTPClient.Post(url, JsonStreamEnvio, JsonStreamRetorno);
except
retorno := HTTPClient.ResponseCode;
end;
retorno := HTTPClient.ResponseCode;
if retorno = 200 then
begin
JsonStreamRetorno.SaveToFile('d:\token.json');
end;
finally
HTTPClient.Free;
SSLIOHandler.Free;
end;
end;
Obrigado Pessoal.