2017-04-01 200 views
0

我正在使用Microsoft的身份框架來使用外部登錄名。除了Facebook以外,所有其他人都在工作。當我使用Facebook時,讓我登錄,但不要求獲得許可,並立即將我返回登錄頁面,而無需獲得授權。身份提供商ASP.NET Facebook身份驗證不起作用

回調URL是http://localhost:14613/signin-facebook/

這是我的外部登錄驗證碼(通過ID和祕密中空白):

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

預期的結果是,它將我重定向到:本地主機/客戶/ ExternalLoginSucceeded

回答

3

我也有過類似的問題,雖然解決了,同時更新以下的NuGet包:

  1. Microsoft.Owin到3.1.0版本
  2. Microsoft.Owin.Security到版本3.1.0
  3. Microsoft.Owin.Security.Cookies到版本3.1.0
  4. Microsoft.Owin.Security.OAuth到版本3.1.0
  5. Microsoft.Owin.Security.Facebook到版本3.1.0

Startup.cs代碼:

var facebookOptions = new FacebookAuthenticationOptions() 
{ 
    AppId = "xxxxxx", 
    AppSecret = "xxxxxx", 
    Scope = { "email" }, 
    Provider = new FacebookAuthenticationProvider() 
     { 
     OnAuthenticated = (context) => 
      { 
       context.Identity.AddClaim(new Claim("urn:facebook:accesstoken", context.AccessToken, ClaimValueTypes.String, "Facebook")); 
       return Task.FromResult(0); 
      } 
     } 
}; 
app.UseFacebookAuthentication(facebookOptions); 

而且我的Facebook圖形API的版本是2.8

+0

固定我的問題 - 謝謝!進一步調查問題後,以下是停止工作的原因:https://github.com/aspnet/AspNetKatana/issues/38 – Rick

0

首先你桅杆有Owin版本

3.1.0

安裝了的NuGet

我發現了一些類似的解決方案,我改變它並更新它以獲得更多的Facebook用戶喜歡的其它功能和是偉大的工作

這裏是代碼(粘貼Startup.Auth):

 var facebookOptions = new FacebookAuthenticationOptions() 
     { 
      AppId =  "-----copy from your facebook app-----", 
      AppSecret = "-----copy from your facebook app-----", 
      Provider = new FacebookAuthenticationProvider 
      { 
       OnAuthenticated = context => 
       { 
        context.Identity.AddClaim(new System.Security.Claims.Claim("FacebookAccessToken", context.AccessToken)); 
        return Task.FromResult(true); 
       } 
      }, 

      //BackchannelHttpHandler = new FacebookBackChannelHandler(), 
      //UserInformationEndpoint = "https://graph.facebook.com/v2.4/me?fields=id,name,email,first_name,last_name,location" 
     }; 
     facebookOptions.Scope.Add("email"); 
     //facebookOptions.Scope.Add("user_likes"); 
     app.UseFacebookAuthentication(facebookOptions);