2015-06-22 50 views
-1

我在Visual Studio 2013中创建了一个标准的ASP.Net Web项目并启用了身份验证。ASP.Net中的Google,Twitter等第三方安全提供商

一个叫做'StartupAuth.cs'的类是自动创建的,具有以下几行。当应用程序在localhost dev服务器上运行时,它会在代码下面的屏幕截图中引发异常。我需要在通过Google,Twitter,Facebook和Window Live进行身份验证时将其运行在localhost dev服务器中。

问题:我可以提供任何有效的字符串值给参数 - clientId,clientSecret和appId吗?如果不是,那么我从哪里获得这些有效值?

 // Uncomment the following lines to enable logging in with third party login providers 
     app.UseMicrosoftAccountAuthentication(
      clientId: "", 
      clientSecret: ""); 

     app.UseTwitterAuthentication(
      consumerKey: "", 
      consumerSecret: ""); 

     app.UseFacebookAuthentication(
      appId: "", 
      appSecret: ""); 

     app.UseGoogleAuthentication(new GoogleOAuth2AuthenticationOptions() 
     { 
      ClientId = "", 
      ClientSecret = "" 
     }); 

认证抛出异常 Authentication Error

更新1

由于OAuth2用户是最新的第三方认证,在以下网址中的说明应使用:http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on。我遵循上述URL中的步骤,发现本地主机上的Google身份验证功能非常完美。

注意:在此URL(http://www.asp.net/web-api/overview/security/external-authentication-services)的说明适用于OpenID身份验证是从最新的OAuth2认证不同,因此不会为谷歌认证工作。

回答

1

不,您不能输入任何字符串。您需要向每个提供商进行注册以获取所需的参数。

有关如何执行此操作的说明,请参见http://www.asp.net/web-api/overview/security/external-authentication-services

+0

看来这个网址可能会提供更多关于外部认证的最新信息,因为OAuth2是当前的趋势:http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app -with-Facebook的和谷歌-的oauth2-和OpenID的登录 – Sunil