Comments (4)
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.
+1 on oAuth Support :)
from restsharp.
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.
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)
- Rely on framework providing STJ HOT 1
- Improve nuget package readme
- support http2 ? HOT 1
- Can't remove Accept-Encoding? HOT 1
- Multipart request sends and then throws NRE HOT 3
- RestResponse is not accessible using DownloadStreamAsync HOT 1
- .NET 8 Compatibility HOT 2
- RestSharp v106.12.0 -> v110.2.0 exception in new RestClient(url); command
- OAuth1 - Path Segments with Special Char "!" - Results in Auth Error HOT 3
- Getting Forbidden when Using ExecuteAsync() HOT 1
- Null Version in RestResponse<T>
- Incorrect value of cookie when the cookie has UTF-8 characters HOT 4
- Not found synchronous operations in restclient HOT 1
- HttpBasicAuthentication in v111.0.0 HOT 1
- OAuth1Authenticator Class missing in 111.0.0 HOT 4
- AddQueryParameter : Pipe character still encoded with false option HOT 2
- Not sending certificates with request HOT 3
- Method in Execute-method new in v111 HOT 5
- Unable to parse JSON response (yesterday I was) HOT 11
- I can't log in to Facebook with version 111, but 108 works HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from restsharp.