Lua
Lua
Generate OAuth 1.0 Signature
Demonstrates how to generate an OAuth 1.0 signature.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local success = false
local oauth = chilkat.OAuth1.new()
-- Set input parameters:
oauth.oauth_version = "1.0"
oauth.oauth_method = "GET"
oauth.oauth_url = "http://echo.lab.madgex.com/echo.ashx"
oauth.consumer_key = "key"
oauth.consumer_secret = "secret"
oauth.token = "accesskey"
oauth.token_secret = "accesssecret"
oauth.nonce = "01020304050607080102030405060708"
oauth.timestamp = "1441659763"
-- Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
oauth.signature_method = "HMAC-SHA256"
success = oauth:generate()
if not success then
print(oauth.last_error_text)
return
end
-- Examine the various outputs:
print(oauth.query_string)
print(oauth.base_string)
print(oauth.hmac_key)
print(oauth.signature)
print(oauth.encoded_signature)
print(oauth.authorization_header)
print(oauth.generated_url)