我試圖實現Facebook登錄使用外部承載令牌。我在VS 2013中創建了一個新項目,並選擇了個人用戶帳戶認證,如在這個調查http://www.asp.net/web-api/overview/security/external-authentication-services中。Facebook登錄使用外部承載令牌(MVC4 Web Api)
我配置了Facebook驗證:
app.UseFacebookAuthentication(
appId: "123[...]",
appSecret: "123[...]");
各項工作的罰款。
我的測試方法:
[OverrideAuthentication]
[HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)]
[Route("ExternalLogin2", Name = "ExternalLogin2")]
public async Task<IHttpActionResult> GetExternalLogin2()
{
ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity);
return Ok();
}
我不知道如何[HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)的作品。
我調用GET請求小提琴手:
GET http://localhost:17353/api/Account/ExternalLogin2 HTTP/1.1
Authorization: Bearer [my facebook token]
Content-Length: 28
Host: localhost:17353
但我收到401結果。
我必須通過外部承載令牌進行身份驗證嗎?
你在哪裏得到來自Facebook的令牌? –
@Neshta你在這裏找到了解決方案嗎? – Syska
這裏同樣的問題。我有一個Facebook標記,但無法訪問標有外部承載的WebAPI方法。 – creatiive