Sample code for 30+ languages & platforms
Lianja

Generate OAuth 1.0 Signature

Demonstrates how to generate an OAuth 1.0 signature.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

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

llSuccess = .F.

loOauth = createobject("CkOAuth1")

// Set input parameters:
loOauth.OauthVersion = "1.0"
loOauth.OauthMethod = "GET"
loOauth.OauthUrl = "http://echo.lab.madgex.com/echo.ashx"
loOauth.ConsumerKey = "key"
loOauth.ConsumerSecret = "secret"
loOauth.Token = "accesskey"
loOauth.TokenSecret = "accesssecret"
loOauth.Nonce = "01020304050607080102030405060708"
loOauth.Timestamp = "1441659763"
// Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
loOauth.SignatureMethod = "HMAC-SHA256"

llSuccess = loOauth.Generate()
if (llSuccess <> .T.) then
    ? loOauth.LastErrorText
    release loOauth
    return
endif

// Examine the various outputs:

? loOauth.QueryString
? loOauth.BaseString
? loOauth.HmacKey
? loOauth.Signature
? loOauth.EncodedSignature
? loOauth.AuthorizationHeader
? loOauth.GeneratedUrl


release loOauth