Sample code for 30+ languages & platforms
Unicode C

Generate OAuth 1.0 Signature

Demonstrates how to generate an OAuth 1.0 signature.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkOAuth1W.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkOAuth1W oauth;

    success = FALSE;

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

    success = FALSE;

    oauth = CkOAuth1W_Create();

    //  Set input parameters:
    CkOAuth1W_putOauthVersion(oauth,L"1.0");
    CkOAuth1W_putOauthMethod(oauth,L"GET");
    CkOAuth1W_putOauthUrl(oauth,L"http://echo.lab.madgex.com/echo.ashx");
    CkOAuth1W_putConsumerKey(oauth,L"key");
    CkOAuth1W_putConsumerSecret(oauth,L"secret");
    CkOAuth1W_putToken(oauth,L"accesskey");
    CkOAuth1W_putTokenSecret(oauth,L"accesssecret");
    CkOAuth1W_putNonce(oauth,L"01020304050607080102030405060708");
    CkOAuth1W_putTimestamp(oauth,L"1441659763");
    //  Can be "HMAC-SHA1", "HMAC-SHA256", "RSA-SHA1", or "RSA-SHA2"
    CkOAuth1W_putSignatureMethod(oauth,L"HMAC-SHA256");

    success = CkOAuth1W_Generate(oauth);
    if (success != TRUE) {
        wprintf(L"%s\n",CkOAuth1W_lastErrorText(oauth));
        CkOAuth1W_Dispose(oauth);
        return;
    }

    //  Examine the various outputs:

    wprintf(L"%s\n",CkOAuth1W_queryString(oauth));
    wprintf(L"%s\n",CkOAuth1W_baseString(oauth));
    wprintf(L"%s\n",CkOAuth1W_hmacKey(oauth));
    wprintf(L"%s\n",CkOAuth1W_signature(oauth));
    wprintf(L"%s\n",CkOAuth1W_encodedSignature(oauth));
    wprintf(L"%s\n",CkOAuth1W_authorizationHeader(oauth));
    wprintf(L"%s\n",CkOAuth1W_generatedUrl(oauth));


    CkOAuth1W_Dispose(oauth);

    }