Search code examples
asp.net-coreasp.net-core-mvcentity-framework-coreasp.net-identity-3

ASP.NET Core UseMicrosoftAccountAuthentication type IApplicationBuilder not defined


I was able to UseMicrosoftAccountAuthentication in ASP.NET 5 Beta 8, but the same code in Startup.cs won't build in RC1

        app.UseMicrosoftAccountAuthentication(options =>
    {
        options.ClientId = "MyClientId";
        options.ClientSecret = "MyClientSecret";
    });

The error is

The type 'IApplicationBuilder' is defined in an assembly that is not referenced. You must add a reference to assembly  'Microsoft.AspNet.Http.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

However the assembly Microsoft.AspNet.Http.Abstractions was not required in Beta 8 and is not available to add to the list of usings.

I have noticed that Microsoft docs always reference using Facebook authentication. Is Microsoft Account authentication as an external provider going away?


Solution

  • It builds for me when I try it with a new web app created with rc1 tooling in VS 2015.

    I add this in dependencies in project.json

    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-rc1-final",
    

    I add this using at the top in Startup.cs

    using Microsoft.AspNet.Authentication.MicrosoftAccount;
    

    I add this code in Configure Method of Startup.cs just before app.UseMvc

    app.UseMicrosoftAccountAuthentication(options =>
    {
        options.ClientId = "MyClientId";
        options.ClientSecret = "MyClientSecret";
    });
    

    It builds fine for me and shows the Microsoft button on the login page though I have not tested it with real credentials.

    I suspect you have some problem in your project.json file, make sure you have updated everything there to rc1 references and anything that was named as Microsoft.Framework.* must be renamed as Microsoft.Extensions.*

    If this doesn't help you get past the problem, then please update your question to include your project.json file contents.