Go
Go
Generate OAuth 1.0 Signature
Demonstrates how to generate an OAuth 1.0 signature.Chilkat Go Downloads
success := false
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
success = false
oauth := chilkat.NewOAuth1()
// Set input parameters:
oauth.SetOauthVersion("1.0")
oauth.SetOauthMethod("GET")
oauth.SetOauthUrl("http://echo.lab.madgex.com/echo.ashx")
oauth.SetConsumerKey("key")
oauth.SetConsumerSecret("secret")
oauth.SetToken("accesskey")
oauth.SetTokenSecret("accesssecret")
oauth.SetNonce("01020304050607080102030405060708")
oauth.SetTimestamp("1441659763")
// Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
oauth.SetSignatureMethod("HMAC-SHA256")
success = oauth.Generate()
if success != true {
fmt.Println(oauth.LastErrorText())
oauth.DisposeOAuth1()
return
}
// Examine the various outputs:
fmt.Println(oauth.QueryString())
fmt.Println(oauth.BaseString())
fmt.Println(oauth.HmacKey())
fmt.Println(oauth.Signature())
fmt.Println(oauth.EncodedSignature())
fmt.Println(oauth.AuthorizationHeader())
fmt.Println(oauth.GeneratedUrl())
oauth.DisposeOAuth1()