I have created a new ASP.net Core 3.0 website, with individual user authentication from the .net project template.
I am storing users by registering directly on the site or using facebook. Here's what my Startup.cs
looks like:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options => {
// This determines user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddDbContext<ApplicationDbContext>(options => {
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
});
services.AddAuthentication()
//.AddMicrosoftAccount(microsoftOptions => { })
//.AddGoogle(googleOptions => { })
//.AddTwitter(twitterOptions => { })
.AddFacebook(facebookOptions =>
{
facebookOptions.AppId = "x";
facebookOptions.AppSecret = "y";
});
...
}
This all works fine and using the default template I can Register/Login as expected.
When I login via Facebook, I'm given five default pieces of claims information about the user:
- name identifier
- email address
- given name
- name
- surname
What I need to do is extend the code so it does more than the default and gives me access to the users:
- phone number
- address
- postcode
(Obviously with the users consent)
I've been reading the documentation (https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/facebook-logins?view=aspnetcore-3.1) but it seems to be more about configuring the authentication provider than additional claims info.
Has anyone done this? Maybe it's not possible?
Thanks for any pointers in advance.