I am building a c# desktop installed application to access Google calendar. I
want to use OAuth Lib to get Access token for the Google user.
Here is my code
==================================================================
UnityContainer unityContainer = new UnityContainer();
UnityConfigurationSection section =
(UnityConfigurationSection)ConfigurationManager.GetSection(“oauth.net.consumer
”);
section.Containers.Default.Configure(unityContainer);
ServiceLocator.SetLocatorProvider(() => new
UnityServiceLocator(unityContainer));
OAuthConsumer oAuthConsumer = new OAuthConsumer(“anonymous”,
“anonymous”, “My application”);
OAuthService oAuthService = OAuthService.Create(new
EndPoint(“https://www.google.com/accounts/OAuthGetRequestToken”), new
Uri(“https://www.google.com/accounts/OAuthAuthorizeToken”), new
EndPoint(“https://www.google.com/accounts/OAuthGetAccessToken”),
oAuthConsumer);
OAuthRequest oAuthRequest = OAuthConsumerRequest.Create(new
EndPoint(GoogleCalendarFeed), oAuthService);
OAuthResponse oAuthResponse = oAuthRequest.GetResource();
======================================================================
Here is my App.config file
======================================================================
<configuration>
<configSections>
<section name="oauth.net.consumer" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/>
</configSections>
<oauth.net.consumer>
<containers>
<container>
<types>
<type type="OAuth.Net.Common.ISigningProvider, OAuth.Net.Common"
mapTo="OAuth.Net.Components.HmacSha1SigningProvider, OAuth.Net.Components"></type>
<type type="OAuth.Net.Common.INonceProvider, OAuth.Net.Common"
mapTo="OAuth.Net.Components.GuidNonceProvider, OAuth.Net.Components" />
</types>
</container>
</containers>
</oauth.net.consumer>
</configuration>
=========================================================================
I am getting error "The remote server returned an error: (401) Unauthorized",
when I call oAuthRequest.GetResource();
what am I doing wrong?
What is the best way to get access token in a installed application?
Thanks
Original issue reported on code.google.com by na.sage...@gmail.com on 8 Jan 2011 at 12:29
Original issue reported on code.google.com by
na.sage...@gmail.com
on 8 Jan 2011 at 12:29