Sample code for 30+ languages & platforms
Delphi ActiveX

Generate OAuth 1.0 Signature

Demonstrates how to generate an OAuth 1.0 signature.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
oauth: TChilkatOAuth1;

begin
success := 0;

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

success := 0;

oauth := TChilkatOAuth1.Create(Self);

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

success := oauth.Generate();
if (success <> 1) then
  begin
    Memo1.Lines.Add(oauth.LastErrorText);
    Exit;
  end;

// Examine the various outputs:

Memo1.Lines.Add(oauth.QueryString);
Memo1.Lines.Add(oauth.BaseString);
Memo1.Lines.Add(oauth.HmacKey);
Memo1.Lines.Add(oauth.Signature);
Memo1.Lines.Add(oauth.EncodedSignature);
Memo1.Lines.Add(oauth.AuthorizationHeader);
Memo1.Lines.Add(oauth.GeneratedUrl);
end;