How do I send spring csrf token from Postman rest client?

前端 未结 6 2186
南方客
南方客 2020-11-28 07:08

I have csrf protection in spring framework. So in each request I send csrf token in header from ajax call, which is perfectly working.

&         


        
6条回答
  •  生来不讨喜
    2020-11-28 07:59

    Firstly you need to install PostMan Interceptor and activate it to have access to the browsers cookies.

    1. You have to fetch the CSRF Token by making a GET Request: Header: "XSRF-TOKEN" and Value: "Fetch"

    2. You should see the Token in the cookie tab and can copy it (Notice: You can configure spring how the cookie should be named. Maybe your cookie has another name than "XSRF-TOKEN". Attention: You have the remove this blank char in the token from the newline)

    3. Now make your POST Request and set the header to: Header: "X-XSRF-TOKEN" and Value: "Your copied Token without blanks"

提交回复
热议问题