PureBasic
PureBasic
Generate OAuth 1.0 Signature
Demonstrates how to generate an OAuth 1.0 signature.Chilkat PureBasic Downloads
IncludeFile "CkOAuth1.pb"
Procedure ChilkatExample()
success.i = 0
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
success = 0
oauth.i = CkOAuth1::ckCreate()
If oauth.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Set input parameters:
CkOAuth1::setCkOauthVersion(oauth, "1.0")
CkOAuth1::setCkOauthMethod(oauth, "GET")
CkOAuth1::setCkOauthUrl(oauth, "http://echo.lab.madgex.com/echo.ashx")
CkOAuth1::setCkConsumerKey(oauth, "key")
CkOAuth1::setCkConsumerSecret(oauth, "secret")
CkOAuth1::setCkToken(oauth, "accesskey")
CkOAuth1::setCkTokenSecret(oauth, "accesssecret")
CkOAuth1::setCkNonce(oauth, "01020304050607080102030405060708")
CkOAuth1::setCkTimestamp(oauth, "1441659763")
; Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
CkOAuth1::setCkSignatureMethod(oauth, "HMAC-SHA256")
success = CkOAuth1::ckGenerate(oauth)
If success <> 1
Debug CkOAuth1::ckLastErrorText(oauth)
CkOAuth1::ckDispose(oauth)
ProcedureReturn
EndIf
; Examine the various outputs:
Debug CkOAuth1::ckQueryString(oauth)
Debug CkOAuth1::ckBaseString(oauth)
Debug CkOAuth1::ckHmacKey(oauth)
Debug CkOAuth1::ckSignature(oauth)
Debug CkOAuth1::ckEncodedSignature(oauth)
Debug CkOAuth1::ckAuthorizationHeader(oauth)
Debug CkOAuth1::ckGeneratedUrl(oauth)
CkOAuth1::ckDispose(oauth)
ProcedureReturn
EndProcedure