Swashbuckle.WebApi icon indicating copy to clipboard operation
Swashbuckle.WebApi copied to clipboard

How to add antiforgery token field in UI that'll be used in headers

Open alvinxiii opened this issue 4 years ago • 0 comments
trafficstars

I have a few HTTP POST end points that require AntiForgery tokens being attached as a e.g header named RequestVerificationToken.

Sample endpoint:

[HttpPost]
[ValidateAntiForgeryToken]
[Route("[controller]/[action]")]
public async Task<IActionResult> Test([FromBody]Type data)

Whenever I click the Try it out button in swagger UI. I always get 403 forbidden access because it failed at AntiForgery.Validate();

How can I make POST call in swagger UI by passing the AntiForgeryToken?

alvinxiii avatar May 21 '21 14:05 alvinxiii