Giter Club home page Giter Club logo

Comments (4)

johnsheehan avatar johnsheehan commented on July 21, 2024

Thanks for creating this ticket. This is definitely on the radar (there's been some work on it already) but it will be after 1.0. Don't worry, the version number is mostly meaningless, I hope 2.0 comes quickly after 1.0 is out.

from restsharp.

joergbattermann avatar joergbattermann commented on July 21, 2024

+1 on oAuth Support :)

from restsharp.

prabirshrestha avatar prabirshrestha commented on July 21, 2024

i got the oauth2 authentication done.
there are many ways we can do oauth2 authentication. the one im gonna show here will be using the URI Query Parameter more details here http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-5.1.2

since oauth2 has lots of authentciation methods. i actually created an abstract class for it.

public abstract class OAuth2Authenticator : IAuthenticator
{
#region Implementation of IAuthenticator

public abstract void Authenticate(RestRequest request);

#endregion

}

then i create specific oauth2 authenticators that is uri paramater.

///
/// based on http://tools.ietf.org/html/draft-ietf-oauth-v2-10#section-5.1.2
///
public class OAuth2UriQueryParamaterAuthenticator : OAuth2Authenticator
{
private readonly string _accessToken;

public OAuth2UriQueryParamaterAuthenticator(string accessToken)
{
    _accessToken = accessToken;
}

#region Overrides of OAuth2Authenticator

public override void Authenticate(RestRequest request)
{
    request.AddParameter("oauth_token", _accessToken, ParameterType.GetOrPost);
}

#endregion

}

so i want to access.. lets say facebook graph api which uses oauth2 for authentication.

var client = new RestClient("https://graph.facebook.com/me");
client.Authenticator =
new OAuth2UriQueryParamaterAuthenticator(
"acces_token");
var request = new RestRequest();
var respone = client.Execute(request);

        Console.WriteLine(respone.Content);

thats all.

actually facebook requires "access_token" parameter. but since it wants to maintain standards it also supports the "oauth_token" parameter instead of "access_token". <:-) that makes our life easier..

from restsharp.

johnsheehan avatar johnsheehan commented on July 21, 2024

oauth1 and 2 now supported in sync methods thanks to contributions from prabir and danielcrenna. async will follow post release 1

from restsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.