I have a very simple web app consisting of the default ASP.NET Core web application to which I've added the Facebook OAuth provider and an Sqlite database.
Got it working locally without any trouble but when I deploy to Azure, I started getting errors.
After a while I got to an error stating:
An error occurred while starting the application
After searching the internet for a couple of hours and trying various ways to actually see the error, I stumbled upon the answer here.
Now I could see the error details:
ArgumentException: The 'ClientId' option must be provided.
Microsoft.AspNetCore.Authentication.OAuth.OAuthMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<TOptions> options)
Microsoft.AspNetCore.Authentication.Facebook.FacebookMiddleware..ctor(RequestDelegate next, IDataProtectionProvider dataProtectionProvider, ILoggerFactory loggerFactory, UrlEncoder encoder, IOptions<SharedAuthenticationOptions> sharedOptions, IOptions<FacebookOptions> options)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.Extensions.Internal.ActivatorUtilities+ConstructorMatcher.CreateInstance(IServiceProvider provider)
Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass3_0.<UseMiddleware>b__0(RequestDelegate next)
Microsoft.AspNetCore.Builder.Internal.ApplicationBuilder.Build()
Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
This is weird because all the documentation I can find online says you should only need AppId and AppSecret for Facebook. I followed the Microsoft guide to get this configured. Here is the relevant bit of Startup.cs:
app.UseFacebookAuthentication(new FacebookOptions()
{
AppId = Configuration["Authentication:Facebook:AppId"],
AppSecret = Configuration["Authentication:Facebook:AppSecret"]
});
I've found examples showing ClientId being used for the Google and Microsoft providers but not Facebook. (it's a big page but just search for 'ClientId') I've tried adding ClientId but just get the same error.