Share via

ASP.NET CORE <> JWT

Anonymous
2023-09-25T07:01:43.4466667+00:00

Capturepostman.JPG Capturebearer.JPG

I added JWT Authentication using 
The Auth Controller C:\Users\allam\source\repos\VisitsApi\VisitsApi\Controllers\AuthController.cs
Returns a Token .
 
The call to https://localhost:7070/api/Visits fails even I pass Token in Postman , how do I fix it
 
		https://github.com/KalyanAllam/VisitsApi

Finally I want to call the api https://localhost:7070/api/Visits from 

https://github.com/KalyanAllam/PatientPortal/blob/master/PatientPortal/Controllers/VisitsNewController.cs


		
Developer technologies | ASP.NET Core | Other
0 comments No comments

Answer accepted by question author

Anonymous
2023-09-25T12:43:46.9433333+00:00

Hi @Dotnet Engineer,

After checking your repo, you should change the ValidIssuer and ValidAudience like below. You are using [https://localhost:5001](https://localhost:5001) which is not same with url in Auth/Login method.

        options.TokenValidationParameters = new TokenValidationParameters
        {
            ValidateIssuer = true,
            ValidateAudience = true,
            ValidateLifetime = true,
            ValidateIssuerSigningKey = true,
            ValidIssuer = "https://localhost:7070",
            ValidAudience = "https://localhost:7070",
            IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("superSecretKey@345"))
        };

If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Best regards,
Jason

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.