9

I am confused which factory OAuth1Authenticator factory method should I use. I think I should get a consumer secret token (can I get it with RestSharp?), then use OAuth1Authenticator.ForRequestToken, then obtain access token and secret access token(how?), then use OAuth1Authenticator.ForAccessToken and use the return value from this point forward.

But it seems that RestSharp is architectured to use the only one authenticator and I can't seem to find a way from a cold start (having only app token) to having all the necessary credentials (consumer key and secret, access key and secret).

Bonus questions:

  1. What .ForClientAuthentication and .ForProtectedResource methods are for?
  2. Why OAuth2Authenticatior is in a different namespace from OAuth1Authenticator?
Sergey Aldoukhov
  • 22,316
  • 18
  • 72
  • 99

1 Answers1

15

OAuth 1 is multi-step, so you have to use a different static method each step of the way. There's an example here: https://github.com/restsharp/RestSharp/blob/master/test/RestSharp.IntegrationTests/OAuth1Tests.cs

chefjuanpi
  • 1,570
  • 15
  • 27
John Sheehan
  • 77,456
  • 30
  • 160
  • 194
  • I guess it can't get more authorial than this ;) – Sergey Aldoukhov Jun 01 '11 at 04:50
  • 1
    There is a step in the code where Process.Start(url); is launched and the user has to copy/paste a token. Is there any way around this to streamline the oAuth Process? – RBZ Mar 15 '13 at 21:23
  • That test uses PIN-based OAuth so that you can actually test it in one go without a URL callback: https://dev.twitter.com/docs/auth/pin-based-authorization. You want to use this flow https://dev.twitter.com/docs/auth/3-legged-authorization and capture the callback values to use in subsequent requests. – John Sheehan Mar 21 '13 at 02:09