How I can to pass parameter to Challenge method, and read it after facebook callback? I want to link social accounts, and id can be user id for example.
Account controller example:
[Route("accounts/facebook/{id}")]
public IActionResult Facebook(string id)
{
var auth = new AuthenticationProperties { RedirectUri = "/accounts/facebook/callback" };
return Challenge(auth, "Facebook");
}
[Route("accounts/facebook/callback")]
public void Callback()
{
//need to read custumId
}
Startup.cs example:
public void ConfigureServices(IServiceCollection services)
{
services
.AddAuthentication()
.AddFacebook(x =>
{
x.AppId = "*";
x.AppSecret = "*";
x.CallbackPath = "/accounts/facebook/callback";
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
Summary, I need to link social accounts to exiting profile in my system.
Very simple - you can pass needed information to query string in redirect uri