接口功能(GetAuthentication)未运行OAuth2Authenticator [英] Interface Function (GetAuthentication) not running OAuth2Authenticator

查看:234
本文介绍了接口功能(GetAuthentication)未运行OAuth2Authenticator的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试使用OAuth2来执行某些程序,问题是Visual Studio 2010跳过了该行

Hi there im trying to use the OAuth2 to do some program the problem is theVisual Studio 2010 skips the line

var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication);


我尝试从google运行示例,并按其示例的预期运行,但是如果我尝试在我的示例中使用它,则它根本无法正常工作,总是会跳过我所引用的行.

这必须是我项目中的某种Visual Studio配置,但我已将其与示例进行了比较,并且外观相同.

有人可以帮我找到解决方法吗?

PS:在Windows 7 x64中运行Visual Studio Ultimate,我环顾了google,在此程序和SO中使用wpf时似乎出现了一些问题,但是这种情况确实存在.

谢谢;)


I tried running the example from google and runs as expected on their sample but if i tried using in my it simply doesnt work always skips the line i refer.

this must be some kind of Visual Studio configuration in my project but i have compared with the sample and it looks the same.

Can some one help me find an resolution for this?

PS: Running Visual Studio Ultimate in Windows 7 x64 i have looked around google and it looks like there some issues working with wpf in this program and SO but this doenst look the case...

Thanks ;)

private void button2_Click(object sender, RoutedEventArgs e){

   var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description);
   provider.ClientIdentifier = "MY Clt ID";
   provider.ClientSecret = "MY CLT Secret";

   var auth = new OAuth2Authenticator<NativeApplicationClient>(provider, GetAuthentication);

   service = new CalendarService(auth);
}

private static IAuthorizationState GetAuthentication(NativeApplicationClient arg){
   Console.Beep();
   
   // Get the auth URL:
IAuthorizationState state = new AuthorizationState(new[] {CalendarService.Scopes.Calendar.GetStringValue() });
   state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
   Uri authUri = arg.RequestUserAuthorization(state);




问题已解决
将功能代码移至Constructor




Problem Solved
Moved function code to Constructor

推荐答案

问题已解决
将功能代码移到了Constructor;)
Problem Solved
Moved function code to Constructor ;)


您能确切地说明如何实现吗?
Can you expand on exactly how you did this?


这篇关于接口功能(GetAuthentication)未运行OAuth2Authenticator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆