Answers
- The problem is that authentication comes after the endpoints are handled in the request pipeline, which means that the user will always be unauthenticated in controller action methods even if the request has a valid access token. This means that protected resources will never be able to be accessed.
UseAuthentication
should come beforeUseEndpoints
in theConfigure
method. - An
AllowAnonymous
attribute can be added to a protected action method to allow unauthenticated users to access it. - The problem is that the ASP.NET Core backend validates that the audience in the JWT is
https://myapp
, but the identity provider has been configured to set the audience tohttp://my-app
. This results in the request being unauthorized. - The
exp
field gives the expiry date, which is1609757875
seconds after January 1, 1970, which, in turn, is January 4, 2021, 10:57:55 (GMT). - The problem is that the HTTP header name needs to be
Authorization
– that is, we have spelled it...