使用 .NET 安装的应用程序的 OAuth
我正在尝试让已安装的应用程序使用 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/[email protected]"}
服务器返回:
Token invalid - Invalid AuthSub token.
有人有想法吗?
实际上,我并没有完全依赖 OAuth,但是 ClientLogin 由于某种原因在今天早上开始工作......无论如何,当用户不必向我的应用程序提供他们的凭据时,我感觉更好。
最好是一个 - 工作 - 示例,无论多么简单:)
我在网上的某个地方读到,带有 OAuth 的 .NET 不能很好地与 GData 1.4.0.2(当前版本)配合使用,并且它与 GData 1.4.0.2(当前版本)配合使用效果更好-experimental-1.5.0.0,但无法找到下载实验版本的位置:(
提前致谢!
I am trying to get OAuth for installed applications to work with my code, with actually little success...
Here is the code:
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);
At the last line, I get an exception:
{"Execution of request failed: http://www.google.com/calendar/feeds/default/owncalendars/[email protected]"}
The server returns:
Token invalid - Invalid AuthSub token.
Anyone with an idea?
I am actually not quite bound to OAuth, but ClientLogin seized working today in the morning for some reason... And anyway, I feel better when the users do not have to provide my application with their credentials.
Best would be a - working - example, no matter how simple :)
I've read somewhere on the net that .NET with OAuth does not work well with GData 1.4.0.2 (current version), and that it is working much better with the - experimental - 1.5.0.0, but was not able to find a locatino to download the experimental version :(
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论