我正在尝试让已安装的应用程序使用OAuth来处理我的代码,但实际上收效甚微......
以下是代码:
GOAuthRequestFactory factory = new GOAuthRequestFactory("cl", "MyApp");
factory.ConsumerKey = "anonymous";
factory.ConsumerSecret = "anonymous";
// example of performing a query (use OAuthUri or query.OAuthRequestorId)
Uri calendarUri = new OAuthUri("http://www.google.com/calendar/feeds/default/owncalendars/full", "firstname.lastname", "gmail.com");
CalendarQuery query = new CalendarQuery();
query.Uri = calendarUri;
factory.AccountType = "GOOGLE";
factory.MethodOverride = true;
Console.WriteLine("Setting up proxy");
IWebProxy iProxy = WebRequest.DefaultWebProxy;
WebProxy myProxy = new WebProxy(iProxy.GetProxy(query.Uri));
// potentially, setup credentials on the proxy here
myProxy.Credentials = CredentialCache.DefaultCredentials;
myProxy.UseDefaultCredentials = true;
factory.Proxy = myProxy;
CalendarService service = new CalendarService("MyApp");
service.RequestFactory = factory;
service.Query(query);
在最后一行,我得到一个例外:
{"Execution of request failed: http://www.google.com/calendar/feeds/default/owncalendars/full?xoauth_requestor_id=firstname.lastname@gmail.com"}
服务器返回:
Token invalid - Invalid AuthSub token.
有想法的人吗?
我实际上并不完全受OAuth限制,但ClientLogin因为某些原因今天早上抓住了工作......无论如何,当用户不必向我的应用程序提供他们的凭据时,我感觉更好。
最好的是 - 工作 - 例如,无论多么简单:)
我已经在网上的某处读到,使用OAuth的.NET与GData 1.4.0.2(当前版本)不兼容,并且它在 - experimental - 1.5.0.0上运行得更好,但是无法使用找到locatino下载实验版:(
提前致谢!