Archived Forum Post

Index of archived forum posts

Question:

OAuth and SetRequestHeader

Jan 21 '13 at 05:43

I have OAuth working using CURL in another app and am trying to port the code over to Chilkat. I'm not using your OAuth sample code as I have an embedded browser and can get an auth_token for the user to update their own status after loggin in. I am generating my own header am attempting to use something like this:

http.SetRequestHeader('Authorization','OAuth oauth_consumer_key="xxxxxx", oauth_nonce="xxxxx", oauth_signature="xxxxx", oauth_signature_method="HMAC-SHA1", oauth_timestamp="xxxxx", oauth_token="xxxxx", oauth_version="1.0"')

And then using your standard http.SynchronousRequest(domain,port,ssl,req) code from the examples.

I know my generated header and tokens are all correct as it works with CURL, so my question is can I set the header using that method?


Accepted Answer

SetRequestHeader is for methods the send HTTP requests but do not use an HttpRequest object (such as QuickGetStr). The SynchronousRequest method's last argument is an HttpRequest object. You would set the header field within the HttpRequest object by calling req.AddHeader.


Answer

Excellent. It worked. Thanks.


Answer

Can you use AddCustomHeader the same way when using the Upload object instead of the HTTPRequest? I swapped things out for this one and changed the method but no luck.