1. Giuseppe moglia
  2. SnapDevelop
  3. Tuesday, 8 September 2020 14:23 PM UTC

Hi Guys

I've followed the steps on this tutorial:

https://docs.appeon.com/snapdevelop2019/Secure_a_Web_API_with_JWT_Token/index.html

But I get always 401 Unauthorized when I try to call the API (After successfull login)

Any hints?

In attachment the code

 

Thanks in advance

Attachments (1)
Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Friday, 11 September 2020 03:13 AM UTC
  2. SnapDevelop
  3. # 1

Hi Giuseppe,

Thank you for reporting this issue. Daryl has provided the correct answer. And we will fix our tutorial later.

You can also refer to ASP.NET Core's document for more details about the Middleware ordering:

https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?tabs=aspnetcore2x&view=aspnetcore-3.1#ordering

Regards,

Logan

Comment
There are no comments made yet.
Daryl Foster Accepted Answer Pending Moderation
  1. Wednesday, 9 September 2020 01:00 AM UTC
  2. SnapDevelop
  3. # 2

Hi Giuseppe,

The order of the middleware in the Configure method of the Startup.cs class is important.  You can try to move these two lines:

app.UseHttpsRedirection();
app.UseAuthentication();

so they are above

app.UseMvc();

 

 

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.