Facebook login using external bearer token (MVC4 Web Api)

Viewed 1528

I'm trying to implement facebook login using external bearer token. I created new project in VS 2013 and selected individual user account authentication like in this tulorial http://www.asp.net/web-api/overview/security/external-authentication-services.

I configured facebook authentication:

app.UseFacebookAuthentication(
            appId: "123[...]",
            appSecret: "123[...]");

And all work fine.

My test method:

[OverrideAuthentication]
[HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)]
[Route("ExternalLogin2", Name = "ExternalLogin2")]
public async Task<IHttpActionResult> GetExternalLogin2()
{
    ExternalLoginData externalLogin = ExternalLoginData.FromIdentity(User.Identity as ClaimsIdentity);
    return Ok();
}

I don't understand how [HostAuthentication(DefaultAuthenticationTypes.ExternalBearer)] works.

I invoke GET request in fiddler:

GET http://localhost:17353/api/Account/ExternalLogin2 HTTP/1.1
Authorization: Bearer [my facebook token]
Content-Length: 28
Host: localhost:17353

But I receive 401 result.

What I must do for authenticating by external bearer token?

1 Answers
Related