Bom dia <@!400344063846645760> !
Temos um exemplo da requisição de autenticação feita pelo Delphi!
Segue a Função
Delphi
///////////
Const
Body = '{"grant_type": "client_credentials"}';
var
sResponse : String;
HttpClient: TIdHTTP;
JsonToSend: TMemoryStream;
AccessToken : iSuperObject;
begin
HttpClient := TIdHTTP.Create( nil );
HttpClient.ConnectTimeout := 20000;
HttpClient.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil);
with TIdSSLIOHandlerSocketOpenSSL(HttpClient.IOHandler).SSLOptions do
begin
CertFile := //Caminho do Certificado do tipo .PEM
KeyFile := //Caminho da chave do Certificado do tipo .PEM
Mode := sslmUnassigned;
SSLVersions := [sslvTLSv1_2];
end;
with HttpClient do
begin
Request.CustomHeaders.Values['Content-Type'] := 'application/json; application/x-www-form-urlencoded;';
Request.ContentType := 'application/json';
Request.CharSet := 'utf-8';
Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Maxthon; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)';
HandleRedirects := True;
HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth];
end;
HttpClient.Request.Username := //Seu ClientId;
HttpClient.Request.Password := //Seu ClientSecret
HttpClient.Request.BasicAuthentication := True;
JsonToSend := TMemoryStream.Create;
WriteStringToStream(JsonToSend, Body, IndyTextEncoding_UTF8);
JsonToSend.Position := 0;
sResponse := HttpClient.Post({A URL Produção/Homologação}+'/oauth/token',JsonToSend);
AccessToken := SO(sResponse);
ShowMessage(AccessToken.S['access_token']);
end;