Hi,

I've been working on Twitter's OAuth implementation, for which I'm using
THttpCli. There are various ways to do this, one of which is adding some
Auth data in the http headers and not including the parameters int he GET
call. However, there's no option in httpcli to manually modify the headers
before a request, so I did a tiny modification on OverbyteIcsHttpProt as
follows:

587:     THttpCli = class(TIcsWndControl)
    protected
        FExtraSendHeader      : String;

913:     published
        property ExtraSendHeader : String            read  FExtraSendHeader
                                                                      write
FExtraSendHeader;

2406: if FExtraSendHeader <> '' then
        begin
          Headers.Add(FExtraSendHeader);
          FExtraSendHeader := '';
        end;

I tested this with an event, which seems to be set properly:

procedure TForm1.UpdatesSocketBeforeHeaderSend(Sender: TObject;
  const Method: string; Headers: TStrings);
begin
  memo1.lines.Add(Headers.Text);
end;

so I fire my Get, and the headers all look correct:


URL = http://api.twitter.com/oauth/request_token
GET /oauth/request_token HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
User-Agent: Mozilla/4.0 (compatible; ICS)
Host: api.twitter.com
Authorization: OAuth oauth_callback="oob", realm="",
oauth_nonce="5B2407849960FC2B4EC23007EA63E8ED",
oauth_timestamp="1297549627", oauth_consumer_key="5BZYtiAzGvQTL0ZEhAn45w",
oauth_signature_method="HMAC-SHA1", oauth_version="1.0",
oauth_signature="RjpaedDdvs6n9yX1TFI%2FNzrnbcQ%3D"

However, this always fails with "Failed to validate oauth signature and
token".

I made sure the data is 100% correct. If I use the parameters in the URL
instead, it works just fine, so they are correct.

Any ideas? anywhere else in the code where the added headers might not be
going through?

For reference: http://oauth.net/core/1.0/#auth_header
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to