Is there a way to view the Authorization Request header when working with OAuth?

642 views
Skip to first unread message

Alex Griciuc

unread,
Nov 18, 2013, 9:28:07 AM11/18/13
to rest...@googlegroups.com
I'm trying to consume OpenTable's API.
They use OAuth 1.0a 2 Legged authorization. From what I've seen in the source the OAuth1Authenticator.ForProtectedResource method was the one to use in order to achieve this, but not matter what I try, I cannot get passed the Invalid Consumer Signature error response from open table.

Here is a slimmed down version of the code, just for testing purposes:

        var client = new RestClient();
        client.BaseUrl = "<URL HERE>";
        client.Authenticator = OAuth1Authenticator.ForProtectedResource("<CONSUMER KEY>", "<CONSUMER SECRET>", string.Empty, string.Empty);

        var request = new RestRequest();
        request.Resource = "restaurant/";
        request.RootElement = "RestaurantDetailsResults";

        request.AddParameter("pid", "1111", ParameterType.QueryString);
        request.AddParameter("rid", "2222", ParameterType.QueryString);
        request.AddParameter("st", "0", ParameterType.QueryString);
        request.AddParameter("offersearchmode", "1", ParameterType.QueryString);

        IRestResponse response = client.Execute(request);

Is there a way to view the exact Authentication header that RestSharp generates based on the above? Has anyone else successfully consumed a rest api with OAuth1 2-legged auth?

Thanks in advance.

Alex Griciuc

unread,
Nov 18, 2013, 10:37:56 AM11/18/13
to rest...@googlegroups.com
LE: Ok, I managed to view the OAuth headers in the request, after it was passed to client.Execute.
The reason why it does not work, is because OpenTable requires the oauth_token param to be present and equal to "", and RestSharp seens to remove parameters that have any empty string as a value.
Is there any way I could add the oauth_token="" param in the OAuth authorization header prior to the call to Authenticate, so it could be included in the generated signature?
Reply all
Reply to author
Forward
0 new messages