代码拉取完成,页面将自动刷新
see this .
传送门 .
QQ and Webchat extensions for Microsoft.AspNetCore.Authentication
// startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// config
app.UseQQAuthentication(new Microsoft.AspNetCore.Authentication.QQ.QQAuthenticationOptions()
{
ClientId = "[you client id]",
ClientSecret ="[you client Secret]",
});
// .... others code ...
}
Then get external login information when login success . eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// get information from AuthenticationManager (using Microsoft.AspNetCore.Authentication.QQ;)
var loginInfo = await HttpContext.Authentication.GetExternalQQLoginInfoAsync();
// todo ...
// .... others code ...
}
// startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// config
app.UseWeixinAuthentication(new Microsoft.AspNetCore.Authentication.Weixin.WeixinAuthenticationOptions()
{
ClientId = "[you client id]",
ClientSecret ="[you client Secret]",
});
// .... others code ...
}
Then get external login information when login success . eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// get information from AuthenticationManager (using Microsoft.AspNetCore.Authentication.Weixin;)
var loginInfo = await HttpContext.Authentication.GetExternalWeixinLoginInfoAsync();
// todo ...
// .... others code ...
}
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
// .... others code ...
// config
services.AddAuthentication()
.AddQQAuthentication(options =>
{
options.ClientId = "[you app id]";
options.ClientSecret = "[you app secret]";
});
// .... others code ...
}
Then get current external login information when login success . eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// get information from HttpContext (using Microsoft.AspNetCore.Authentication.QQ;)
var loginInfo = await HttpContext.GetExternalQQLoginInfoAsync();
// todo ...
// .... others code ...
}
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
// .... others code ...
// config
services.AddAuthentication()
.AddWeixinAuthentication(options =>
{
options.ClientId = "[you app id]";
options.ClientSecret = "[you app secret]";
});
// .... others code ...
}
Then get current external login information when login success . eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// get information from HttpContext (using Microsoft.AspNetCore.Authentication.Weixin;)
var loginInfo = await HttpContext.GetExternalWeixinLoginInfoAsync();
// todo ...
// .... others code ...
}
QQ 和 微信 Microsoft.AspNetCore.Authentication 扩展
// startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// 配置
app.UseQQAuthentication(new Microsoft.AspNetCore.Authentication.QQ.QQAuthenticationOptions()
{
ClientId = "[you client id]",
ClientSecret ="[you client Secret]",
});
// .... others code ...
}
获取登陆成功后的信息。 eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// 获取登录者信息 (using Microsoft.AspNetCore.Authentication.QQ;)
var loginInfo = await HttpContext.Authentication.GetExternalQQLoginInfoAsync();
// todo ...
// .... others code ...
}
// startup.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// 配置
app.UseWeixinAuthentication(new Microsoft.AspNetCore.Authentication.Weixin.WeixinAuthenticationOptions()
{
ClientId = "[you client id]",
ClientSecret ="[you client Secret]",
});
// .... others code ...
}
获取登陆成功后的信息。 eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// 获取登录者信息 (using Microsoft.AspNetCore.Authentication.Weixin;)
var loginInfo = await HttpContext.Authentication.GetExternalWeixinLoginInfoAsync();
// todo ...
// .... others code ...
}
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
// .... others code ...
// 配置
services.AddAuthentication()
.AddQQAuthentication(options =>
{
options.ClientId = "[you app id]";
options.ClientSecret = "[you app secret]";
});
// .... others code ...
}
获取登陆成功后的信息。 eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// 获取登录者信息 (using Microsoft.AspNetCore.Authentication.QQ;)
var loginInfo = await HttpContext.GetExternalQQLoginInfoAsync();
// todo ...
// .... others code ...
}
// startup.cs
public void ConfigureServices(IServiceCollection services)
{
// .... others code ...
// 配置
services.AddAuthentication()
.AddWeixinAuthentication(options =>
{
options.ClientId = "[you app id]";
options.ClientSecret = "[you app secret]";
});
// .... others code ...
}
获取登陆成功后的信息。 eg: AccountController
// GET: /Account/ExternalLoginCallback
[HttpGet]
[AllowAnonymous]
public async Task<IActionResult> ExternalLoginCallback(string returnUrl = null, string remoteError = null)
{
// .... others code ...
// .....
// 获取登录者信息 (using Microsoft.AspNetCore.Authentication.Weixin;)
var loginInfo = await HttpContext.GetExternalWeixinLoginInfoAsync();
// todo ...
// .... others code ...
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型