Delphi DLL
Delphi DLL
Generate OAuth 1.0 Signature
Demonstrates how to generate an OAuth 1.0 signature.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, OAuth1;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
oauth: HCkOAuth1;
begin
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) then
begin
Memo1.Lines.Add(CkOAuth1__lastErrorText(oauth));
Exit;
end;
// Examine the various outputs:
Memo1.Lines.Add(CkOAuth1__queryString(oauth));
Memo1.Lines.Add(CkOAuth1__baseString(oauth));
Memo1.Lines.Add(CkOAuth1__hmacKey(oauth));
Memo1.Lines.Add(CkOAuth1__signature(oauth));
Memo1.Lines.Add(CkOAuth1__encodedSignature(oauth));
Memo1.Lines.Add(CkOAuth1__authorizationHeader(oauth));
Memo1.Lines.Add(CkOAuth1__generatedUrl(oauth));
CkOAuth1_Dispose(oauth);
end;