3
我正在学习如何使用Google Calendar API,这反过来又要求我学习如何使用DotNetOpenAuth访问Google帐户。我使提供的示例工作,并在控制台程序中编写了工作代码以访问和操作日历。如何为DotNetOpenAuth编写VB或C#GUI客户端?
我现在想写一个Windows窗体应用程序(在C#或VB)做同样的事情。我无法使OAuth2进程在GUI应用程序中工作。它编译并运行,但不起作用。基于迄今为止我所看到的,我已经得出结论:GetAuthorization()函数未被调用。
我已经尝试从按钮单击,从构造函数和窗体Loader方法开始该过程。我已经尝试了C#和VB。
public GoogleCal()
{
InitializeComponent();
var provider = new NativeApplicationClient(
GoogleAuthenticationServer.Description);
provider.ClientIdentifier = "xxxxx.apps.googleusercontent.com";
provider.ClientSecret = "yyyyy";
var auth = new OAuth2Authenticator<NativeApplicationClient>(
provider, GetAuthorization);
}
private IAuthorizationState GetAuthorization(NativeApplicationClient arg)
{
// Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] {
CalendarService.Scopes.Calendar.GetStringValue() });
state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
Uri authUri = arg.RequestUserAuthorization(state);
// Request authorization from the user (by opening a browser window):
Process.Start(authUri.ToString());
authCodeText = Microsoft.VisualBasic.Interaction.InputBox(
"Paste code:", "title", "");
// Retrieve the access token by using the authorization code:
return arg.ProcessUserAuthorization(authCodeText, state);
}
我明显做错了什么,但我无法弄清楚它是什么。有任何想法吗?
这是一个类似的问题,但不是我所问的。 (另一方面,它可能尽可能接近我所能得到的......)那里讨论的解决方案似乎只有.asp。我正在寻找只有c#或vb的东西。 – Brian 2012-03-13 22:05:10
ASP是vb或C#你不是在找东西.net只是vb6?或者也许winforms或wpf?没有足够的信息来获取所需的信息 – 2012-03-13 22:45:32
我试图创建一个Windows窗体应用程序VS 2010. 2010. – Brian 2012-03-14 00:51:13