To Bring you up to speed where I am right now, because I have this talking to Yahoo, just I don't have the workflow figured out from this API. Getting there.
But anyways, there is some setup.
The easiest way to get this working is to use the sample provided from the oauth-dot-net 0.8 source package.
If you build the projects, then go into the bin directory of one of them, you will get all the libraries you need.
Add a reference to them all.
You will need for sure, the Castle.* ones, the Oauth.* ones and the Microsoft.Practices.ServiceLocation
Once this is complete, you will need to add an App.Config (or Web.Config) if you havent already.
Add a section to the configuration file like this.
CODEBOX
<oauth.net.consumer>
<!-- Components -->
<components>
<!-- Signing provider for HMAC-SHA1 -->
<component id="signing.provider:HMAC-SHA1" service="OAuth.Net.Common.ISigningProvider, OAuth.Net.Common" type="OAuth.Net.Components.HmacSha1SigningProvider, OAuth.Net.Components" lifestyle="thread"/>
<!-- Nonce provider -->
<component id="nonce.provider" service="OAuth.Net.Common.INonceProvider, OAuth.Net.Common" type="OAuth.Net.Components.GuidNonceProvider, OAuth.Net.Components"/>
</components>
</oauth.net.consumer>
And under <configSections> add:
CODEBOX
<section name="oauth.net.consumer" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
my app config looks like this:
CODEBOX
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="oauth.net.consumer" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/>
</configSections>
<oauth.net.consumer>
<!-- Components -->
<components>
<!-- Signing provider for HMAC-SHA1 -->
<component id="signing.provider:HMAC-SHA1" service="OAuth.Net.Common.ISigningProvider, OAuth.Net.Common" type="OAuth.Net.Components.HmacSha1SigningProvider, OAuth.Net.Components" lifestyle="thread"/>
<!-- Nonce provider -->
<component id="nonce.provider" service="OAuth.Net.Common.INonceProvider, OAuth.Net.Common" type="OAuth.Net.Components.GuidNonceProvider, OAuth.Net.Components"/>
</components>
</oauth.net.consumer>
</configuration>
Once you have this in place, you need to make the library read it. If you have a web project, you can use the Global.asax,
if you have a desktop application, you can do something like this:
CODEBOX
class Program {
static void Main(string[] args) {
IServiceLocator injector =
new WindsorServiceLocator(
new WindsorContainer(
new XmlInterpreter(
new ConfigResource("oauth.net.consumer"))));
ServiceLocator.SetLocatorProvider(() => injector);
return;
}
}
It might be a good idea for you to add your key and secret to your app.config, or you can hard code it.
When you use oauth-dot-net as a consumer, you will need to be using the following namespaces:
CODEBOX
using OAuth.Net.Consumer;
using OAuth.Net.Components;
now your code would look like this:
CODEBOX
OAuthConsumer consumer = new OAuthConsumer(
"key",
"secret");
EndPoint epRequest = new EndPoint("https://api.login.yahoo.com/oauth/v2/get_request_token");
Uri uriRequestAuth = new Uri("https://api.login.yahoo.com/oauth/v2/request_auth");
EndPoint epAccessToken = new EndPoint("https://api.login.yahoo.com/oauth/v2/get_token");
OAuthService serviceDefinition;
serviceDefinition = OAuthService.Create(
epRequest,
uriRequestAuth,
epAccessToken,
"HMAC-SHA1",
consumer);
and this is where I'm playing right now. Right off the bat, this is not handing in the tokens that you would get from authenticating, but trying to fire a request will bring back the token you get from get_request_token,
so this is where I am working out how this library handles that workflow. I would probably explicitly force it, by passing in the parameters from each successive call back in, because the library seems to know the state of that negotiation anyways. But because of that, I figures it has a slick way of handling it.
So.. thats what I have, enjoy, I figure I'll have this sorted out tomorrow sometime.
Not much documentation on this product is there? =)