![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Example: Http.SetOAuthRsaKey methodDemonstrates the
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkPrivateKey.pb" IncludeFile "CkPfx.pb" Procedure ChilkatExample() success.i = 0 pfx.i = CkPfx::ckCreate() If pfx.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkPfx::ckLoadPfxFile(pfx,"qa_data/pfx/MCD_Sandbox_chilkat_iccp_API_Keys/chilkat_iccp-sandbox.p12","keystorepassword") If success = 0 Debug CkPfx::ckLastErrorText(pfx) CkPfx::ckDispose(pfx) ProcedureReturn EndIf privKey.i = CkPrivateKey::ckCreate() If privKey.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkPfx::ckPrivateKeyAt(pfx,0,privKey) If success = 0 Debug CkPfx::ckLastErrorText(pfx) CkPfx::ckDispose(pfx) CkPrivateKey::ckDispose(privKey) ProcedureReturn EndIf http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Use OAuth1.0a authentication. CkHttp::setCkOAuth1(http, 1) ; Use your own consumer key (this is not a valid consumer key) CkHttp::setCkOAuthConsumerKey(http, "123abc") CkHttp::setCkOAuthSigMethod(http, "RSA-SHA256") success = CkHttp::ckSetOAuthRsaKey(http,privKey) If success = 0 Debug CkHttp::ckLastErrorText(http) CkPfx::ckDispose(pfx) CkPrivateKey::ckDispose(privKey) CkHttp::ckDispose(http) ProcedureReturn EndIf ; Tell Chilkat to automatically calculate and add the oauth_body_hash field when sending the request. CkHttp::setCkOAuthBodyHash(http, 1) ; Send this request to an endpoint at chilkatsoft.com. The purpose of this example is to show ; how the OAuth1.0a Authorization header is computed and sent by Chilkat. ; The chilkatsoft.com site itself doesn't do OAuth1. It's just ignoring the Authorization header. resp.i = CkHttpResponse::ckCreate() If resp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkHttp::ckHttpStr(http,"POST","https://chilkatsoft.com/echo_request_body.asp","<notUsed>123</notUsed>","utf-8","application/xml",resp) If success = 0 Debug CkHttp::ckLastErrorText(http) CkPfx::ckDispose(pfx) CkPrivateKey::ckDispose(privKey) CkHttp::ckDispose(http) CkHttpResponse::ckDispose(resp) ProcedureReturn EndIf ; Examine the request header we just sent.. Debug CkHttp::ckLastHeader(http) ; Sample output: ; POST /echo_request_body.asp HTTP/1.1 ; Host: chilkatsoft.com ; Accept: */* ; Accept-Encoding: gzip ; Content-Type: application/xml ; Content-Length: 22 ; Authorization: OAuth oauth_consumer_key="123abc", oauth_nonce="A2E91C3B53E0BD7FBF71F441336679E358DDCEEE", oauth_body_hash="a5kPTsDwUwmBjC0voNlAAvM6YoaRS5X7sTO49jl3/h8=", oauth_timestamp="1756324932", oauth_signature_method="RSA-SHA256", oauth_version="1.0", oauth_signature="*****" CkPfx::ckDispose(pfx) CkPrivateKey::ckDispose(privKey) CkHttp::ckDispose(http) CkHttpResponse::ckDispose(resp) ProcedureReturn EndProcedure |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.