C
C
Generate OAuth 1.0 Signature
Demonstrates how to generate an OAuth 1.0 signature.Chilkat C Downloads
#include <C_CkOAuth1.h>
void ChilkatSample(void)
{
BOOL success;
HCkOAuth1 oauth;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
success = FALSE;
oauth = CkOAuth1_Create();
// Set input parameters:
CkOAuth1_putOauthVersion(oauth,"1.0");
CkOAuth1_putOauthMethod(oauth,"GET");
CkOAuth1_putOauthUrl(oauth,"http://echo.lab.madgex.com/echo.ashx");
CkOAuth1_putConsumerKey(oauth,"key");
CkOAuth1_putConsumerSecret(oauth,"secret");
CkOAuth1_putToken(oauth,"accesskey");
CkOAuth1_putTokenSecret(oauth,"accesssecret");
CkOAuth1_putNonce(oauth,"01020304050607080102030405060708");
CkOAuth1_putTimestamp(oauth,"1441659763");
// Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
CkOAuth1_putSignatureMethod(oauth,"HMAC-SHA256");
success = CkOAuth1_Generate(oauth);
if (success != TRUE) {
printf("%s\n",CkOAuth1_lastErrorText(oauth));
CkOAuth1_Dispose(oauth);
return;
}
// Examine the various outputs:
printf("%s\n",CkOAuth1_queryString(oauth));
printf("%s\n",CkOAuth1_baseString(oauth));
printf("%s\n",CkOAuth1_hmacKey(oauth));
printf("%s\n",CkOAuth1_signature(oauth));
printf("%s\n",CkOAuth1_encodedSignature(oauth));
printf("%s\n",CkOAuth1_authorizationHeader(oauth));
printf("%s\n",CkOAuth1_generatedUrl(oauth));
CkOAuth1_Dispose(oauth);
}