Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Shopify Private Authentication for Private AppsShopify private authentication is for interacting with your own store through private applications. It uses HTTP "Basic" authentication with your Shopify private application key and secret key. This example demonstrates how to send a private authenticated request using Chilkat Http, and then the same using Chilkat Rest.
integer li_rc oleobject loo_Http oleobject loo_Resp oleobject loo_SbJson oleobject loo_Json oleobject loo_Rest integer li_BTls integer li_Port integer li_BAutoReconnect integer li_Success // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // First demonstrate sending a simple request using Shopify private authentication w/ the Chilkat Http API. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // To use HTTP Basic Authentication with any HTTP request, we simply set the Login, Password, and BasicAuth properties. // Important: All HTTP requests using Basic authentication must be over SSL/TLS. loo_Http.Login = "SHOPIFY_PRIVATE_API_KEY" loo_Http.Password = "SHOPIFY_PRIVATE_API_SECRET_KEY" loo_Http.BasicAuth = 1 // Make sure to replace "chilkat" with your store name. loo_Resp = loo_Http.QuickGetObj("https://chilkat.myshopify.com/admin/products.json") if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http return end if // Examine the response code. if loo_Resp.StatusCode <> 200 then Write-Debug "Received error response code: " + string(loo_Resp.StatusCode) Write-Debug "Response body:" Write-Debug loo_Resp.BodyStr destroy loo_Resp destroy loo_Http return end if // Success. Write-Debug "Success." // Examine the JSON response loo_SbJson = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbJson.ConnectToNewObject("Chilkat.StringBuilder") loo_Resp.GetBodySb(loo_SbJson) destroy loo_Resp loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.LoadSb(loo_SbJson) loo_Json.EmitCompact = 0 Write-Debug loo_Json.Emit() // ------------------------------------------------- // Now let's do the same using the Chilkat Rest API. loo_Rest = create oleobject // Use "Chilkat_9_5_0.Rest" for versions of Chilkat < 10.0.0 li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest") // Provide the private app credentials: loo_Rest.SetAuthBasic("SHOPIFY_PRIVATE_API_KEY","SHOPIFY_PRIVATE_API_SECRET_KEY") // Connect to the shopify server. li_BTls = 1 li_Port = 443 li_BAutoReconnect = 1 // Make sure to replace "chilkat" with your store name. li_Success = loo_Rest.Connect("chilkat.myshopify.com",li_Port,li_BTls,li_BAutoReconnect) if li_Success <> 1 then Write-Debug loo_Rest.LastErrorText destroy loo_Http destroy loo_SbJson destroy loo_Json destroy loo_Rest return end if loo_SbJson.Clear() li_Success = loo_Rest.FullRequestNoBodySb("GET","/admin/products.json",loo_SbJson) if loo_Rest.LastMethodSuccess <> 1 then Write-Debug loo_Rest.LastErrorText destroy loo_Http destroy loo_SbJson destroy loo_Json destroy loo_Rest return end if if loo_Rest.ResponseStatusCode <> 200 then Write-Debug "Received error response code: " + string(loo_Rest.ResponseStatusCode) Write-Debug "Response body:" Write-Debug loo_SbJson.GetAsString() destroy loo_Http destroy loo_SbJson destroy loo_Json destroy loo_Rest return end if // Success... loo_Json.LoadSb(loo_SbJson) Write-Debug loo_Json.Emit() destroy loo_Http destroy loo_SbJson destroy loo_Json destroy loo_Rest |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.