我在.net核心1.1中创建了一个web。我已经使用Auth0来验证它的社会登录。选择的客户端类型是“API的测试版”。我在.net核心1.1中创建了另一个web应用程序,它使用另一个Auth0常规Web应用程序来验证社交登录。
这是否可以使用由web应用程序创建的访问令牌作为授权头传递并获得对web方法的访问权?
谢谢你,森迪尔
发布于 2016-12-13 15:08:53
我在Auth0上写了一篇关于基于ASP.NET核的JWT令牌的API认证和如何使用自动休息创建客户端的文章。
这篇文章有一个公共GitHub回购,可以使用整个场景(Web + API)。
基本上,您将传递JWT令牌并在API上验证它,并在Startup.cs上使用以下内容进行验证:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
/*Enabling swagger file*/
app.UseSwagger();
/*Enabling Swagger ui, consider doing it on Development env only*/
app.UseSwaggerUi();
/*It's important that this is AFTER app.UseSwagger or the swagger.json file would be innaccesible*/
var options = new JwtBearerOptions
{
Audience = Configuration["auth0:clientId"],
Authority = $"https://{Configuration["auth0:domain"]}/"
};
app.UseJwtBearerAuthentication(options);
/*Normal MVC mappings*/
app.UseMvc();}
https://stackoverflow.com/questions/41110283
复制相似问题