(Delphi ActiveX) Shopware Digest Authentication
Demonstrates using Digest access authentication for Shopware. For more information, see https://developers.shopware.com/developers-guide/rest-api/#digest-access-authentication
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
http: TChilkatHttp;
sbResponseBody: TChilkatStringBuilder;
success: Integer;
jResp: TChilkatJsonObject;
begin
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := TChilkatHttp.Create(Self);
// To use HTTP Digest Authentication, set the login and password, and also indicate that DigestAuth should be used.
http.Login := 'api_username';
http.Password := 'api_key';
http.DigestAuth := 1;
sbResponseBody := TChilkatStringBuilder.Create(Self);
success := http.QuickGetSb('https://my-shopware-shop.com/api/articles?limit=2',sbResponseBody.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
jResp := TChilkatJsonObject.Create(Self);
jResp.LoadSb(sbResponseBody.ControlInterface);
jResp.EmitCompact := 0;
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(jResp.Emit());
end;
|