How to use RestSharp with OAuth?

19,838

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

Share:
19,838

Related videos on Youtube

Sergey Aldoukhov
Author by

Sergey Aldoukhov

Delphi and WPF developer in the past Now - iOS, Android and Windows

Updated on June 04, 2022

Comments

  • Sergey Aldoukhov
    Sergey Aldoukhov almost 2 years

    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
    Sergey Aldoukhov almost 13 years
    I guess it can't get more authorial than this ;)
  • RBZ
    RBZ about 11 years
    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?
  • John Sheehan
    John Sheehan about 11 years
    That test uses PIN-based OAuth so that you can actually test it in one go without a URL callback: dev.twitter.com/docs/auth/pin-based-authorization. You want to use this flow dev.twitter.com/docs/auth/3-legged-authorization and capture the callback values to use in subsequent requests.