Sample code for 30+ languages & platforms
Tcl

Generate OAuth 1.0 Signature

Demonstrates how to generate an OAuth 1.0 signature.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

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

set success 0

set oauth [new_CkOAuth1]

# Set input parameters:
CkOAuth1_put_OauthVersion $oauth "1.0"
CkOAuth1_put_OauthMethod $oauth "GET"
CkOAuth1_put_OauthUrl $oauth "http://echo.lab.madgex.com/echo.ashx"
CkOAuth1_put_ConsumerKey $oauth "key"
CkOAuth1_put_ConsumerSecret $oauth "secret"
CkOAuth1_put_Token $oauth "accesskey"
CkOAuth1_put_TokenSecret $oauth "accesssecret"
CkOAuth1_put_Nonce $oauth "01020304050607080102030405060708"
CkOAuth1_put_Timestamp $oauth "1441659763"
# Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
CkOAuth1_put_SignatureMethod $oauth "HMAC-SHA256"

set success [CkOAuth1_Generate $oauth]
if {$success != 1} then {
    puts [CkOAuth1_lastErrorText $oauth]
    delete_CkOAuth1 $oauth
    exit
}

# Examine the various outputs:

puts [CkOAuth1_queryString $oauth]
puts [CkOAuth1_baseString $oauth]
puts [CkOAuth1_hmacKey $oauth]
puts [CkOAuth1_signature $oauth]
puts [CkOAuth1_encodedSignature $oauth]
puts [CkOAuth1_authorizationHeader $oauth]
puts [CkOAuth1_generatedUrl $oauth]

delete_CkOAuth1 $oauth