Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net UseJwtBeareAuthentication返回401_Asp.net_.net_Asp.net Web Api_Firebase Authentication_.net Core - Fatal编程技术网

Asp.net UseJwtBeareAuthentication返回401

Asp.net UseJwtBeareAuthentication返回401,asp.net,.net,asp.net-web-api,firebase-authentication,.net-core,Asp.net,.net,Asp.net Web Api,Firebase Authentication,.net Core,我在应用程序堆栈中使用Firebase和dotnet core 我正在使用Firebase iOS API生成JWT fine,并可以使用的解析器确认该结构是否如预期的那样有效 设置 我已经遵循设置dotnet core的步骤,根据请求自动设置主体 我的启动文件的configure方法如下所示,在实践中,部分被项目应用程序替换(我可以确认它与JWT.io中解析的JWT中的aud属性相同): 问题 我一直在谷歌上搜索和搜寻源代码,我简直无法破解这个 有人能看出我做错了什么吗 以下是我的项目中的所有

我在应用程序堆栈中使用Firebase和dotnet core

我正在使用Firebase iOS API生成JWT fine,并可以使用的解析器确认该结构是否如预期的那样有效

设置 我已经遵循设置dotnet core的步骤,根据请求自动设置主体

我的启动文件的configure方法如下所示,在实践中,
部分被项目应用程序替换(我可以确认它与JWT.io中解析的JWT中的
aud
属性相同):

问题 我一直在谷歌上搜索和搜寻源代码,我简直无法破解这个

有人能看出我做错了什么吗

以下是我的项目中的所有依赖项版本:

<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.4.0" />
<PackageReference Include="Serilog.Sinks.ElasticSearch" Version="5.3.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.2" />

默认情况下,该密钥似乎已被添加。您可能需要将密钥添加到帖子中。
键:
授权
值:
持有人eyjhbGciOij…

这是必要的,在谷歌API后,以允许一个安全的连接。仪表板会自动将此键添加到中

来源:

以前使用谷歌API的经验,所以。。。结果表明,它不起作用的可能原因是我一直在玩的代币过期了。我今天生成了另一个,并再次尝试了postman查询,结果成功了


所以如果你也有同样的问题,不要犯我愚蠢的错误,确保你有一个没有过期的代币

令牌中是否存在允许生成有效原则的有效声明?堆栈跟踪似乎无法识别用户。这有时可能是因为无法验证令牌签名。
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 GET http://localhost:5000/api/dashboard  
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:5000/api/dashboard  
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
      Authorization failed for user: (null).
Microsoft.AspNetCore.Authorization.DefaultAuthorizationService:Information: Authorization failed for user: (null).
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
      Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
info: Microsoft.AspNetCore.Mvc.ChallengeResult[1]
      Executing ChallengeResult with authentication schemes ().
Microsoft.AspNetCore.Mvc.ChallengeResult:Information: Executing ChallengeResult with authentication schemes ().
info: Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware[12]
      AuthenticationScheme: Bearer was challenged.
Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerMiddleware:Information: AuthenticationScheme: Bearer was challenged.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
      Executed action Sured.Api.Controllers.DashboardController.Get (Sured.Api) in 20.2369ms
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action Sured.Api.Controllers.DashboardController.Get (Sured.Api) in 20.2369ms
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 37.6488ms 401 
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Serilog" Version="2.5.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.4.0" />
<PackageReference Include="Serilog.Sinks.ElasticSearch" Version="5.3.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.2" />