2015-06-22 66 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