如何在没有身份的情况下将参数传递给 ASP.NE Core 2.1 中的 fb auth 回调?
How to pass parameter to fb auth callback in ASP.NE Core 2.1, without identity?
如何将参数传递给Challenge方法,并在facebook回调后读取?我想link个社交账号,id可以是用户id例如
帐户控制器示例:
[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 示例:
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?}");
});
}
总结,我需要 link 社交帐户才能退出我系统中的个人资料。
非常简单 - 您可以将需要的信息传递给重定向 uri 中的查询字符串
如何将参数传递给Challenge方法,并在facebook回调后读取?我想link个社交账号,id可以是用户id例如
帐户控制器示例:
[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 示例:
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?}");
});
}
总结,我需要 link 社交帐户才能退出我系统中的个人资料。
非常简单 - 您可以将需要的信息传递给重定向 uri 中的查询字符串