(Delphi ActiveX) Shopify OAuth2 Authentication: Get List of Products
Demonstrates how to send a simple HTTP GET request with OAuth2 to get a list of products. The OAuth2 access token was obtained from the Shopify developer console for the created custom app.
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;
jsonStr: WideString;
begin
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := TChilkatHttp.Create(Self);
http.SetRequestHeader('X-Shopify-Access-Token','admin_api_access_token');
jsonStr := http.QuickGetStr('https://mystore.myshopify.com/admin/api/2022-04/products.json');
if (http.LastMethodSuccess <> 1) then
begin
Memo1.Lines.Add(http.LastErrorText);
Exit;
end;
Memo1.Lines.Add('Response status code: ' + IntToStr(http.LastStatus));
Memo1.Lines.Add('JSON response:');
Memo1.Lines.Add(jsonStr);
end;
|