Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) Walmart Partner API Authentication (Generate a Signature for a Request)

Demonstrates how to generate a signature for a Walmart Partner REST API call.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Boolean iSuccess
    String sConsumerId
    String sBaseUrl
    String sPrivateEncodedStr
    String sHttpMethod
    Handle hoDt
    Boolean iBLocal
    Integer iTimeStampVal
    Handle hoSbStringToSign
    Variant vPrivKey
    Handle hoPrivKey
    Handle hoRsa
    String sSignatureString
    String sTemp1
    Boolean bTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Move "b68d2a72...." To sConsumerId
    Move "https://marketplace.walmartapis.com/v2/feeds" To sBaseUrl
    // This is your Base64 encoded private key
    Move "MIICeAIBADANBgkqhkiG9w0BAQEFAA......" To sPrivateEncodedStr
    Move "GET" To sHttpMethod

    // We need a timestamp in decimal string form representing the number of milliseconds since Jan 01 1970 UTC.
    Get Create (RefClass(cComCkDateTime)) To hoDt
    If (Not(IsComObjectCreated(hoDt))) Begin
        Send CreateComObject of hoDt
    End
    // Set bLocal = True for a timestamp in the local timezone.  Set bLocal = False for a UTC timestamp.
    Move False To iBLocal
    // This gets the timestamp in seconds, not milliseconds.
    Get ComGetAsUnixTime Of hoDt iBLocal To iTimeStampVal

    // Build the string to sign.
    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbStringToSign
    If (Not(IsComObjectCreated(hoSbStringToSign))) Begin
        Send CreateComObject of hoSbStringToSign
    End
    Get ComAppend Of hoSbStringToSign sConsumerId To iSuccess
    Get ComAppend Of hoSbStringToSign (character(10)) To iSuccess
    Get ComAppend Of hoSbStringToSign sBaseUrl To iSuccess
    Get ComAppend Of hoSbStringToSign (character(10)) To iSuccess
    Get ComAppend Of hoSbStringToSign sHttpMethod To iSuccess
    Get ComAppend Of hoSbStringToSign (character(10)) To iSuccess
    Get ComAppendInt Of hoSbStringToSign iTimeStampVal To iSuccess
    // We add three zero's so that the timestamp value is in milliseconds.
    // We don't care about accuracy down to less than a second.
    // All the server cares about is that the request was signed at the current date/time
    // within some reasonable margin of error (to account for systems having clocks
    // that may be slightly different).
    Get ComAppend Of hoSbStringToSign "000" + (character(10)) To iSuccess

    Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey
    If (Not(IsComObjectCreated(hoPrivKey))) Begin
        Send CreateComObject of hoPrivKey
    End
    // Load the private key into a private key object.
    // Note: Technically the private key is not PEM because it lacks the header/footer strings
    // used for PEM.  However, the LoadPem method will still accept it and load it correctly.
    Get ComLoadPem Of hoPrivKey sPrivateEncodedStr To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoPrivKey To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatRsa)) To hoRsa
    If (Not(IsComObjectCreated(hoRsa))) Begin
        Send CreateComObject of hoRsa
    End
    Get pvComObject of hoPrivKey to vPrivKey
    Get ComImportPrivateKeyObj Of hoRsa vPrivKey To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoRsa To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // We want a base64 signature string.
    Set ComEncodingMode Of hoRsa To "base64"

    Get ComGetAsString Of hoSbStringToSign To sTemp1
    Get ComSignStringENC Of hoRsa sTemp1 "SHA256" To sSignatureString
    Get ComLastMethodSuccess Of hoRsa To bTemp1
    If (bTemp1 <> True) Begin
        Get ComLastErrorText Of hoRsa To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Signature String: " sSignatureString


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.