There is a drupal 9 site that has a REST-endpoint that can be accessed for logged-in users (not for anonymous ones).
And, it's necessary to make a GET request to the endpoint using cookie authentication.
Could you clarify, what the correct algorithm of this request is?
I tried to do it two ways.
Way #1.
Send a POST-request to user/login with credentials and get CSRF-token, then use the token in headers of GET-request to my endpoint. No result.
Way #2.
Send a POST-request to user/login with credentials, then send a GET-request to session/token and get token from. After that, use this token from session/token in my GET request.
Also, no result.
In both cases, it returns the 401 error (from Insomnia) or the 403 error (from external JavaScript).
My headers to GET request are
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': token
}
The cookie authentication is checked for my REST endpoint in REST UI.
What am I doing wrong?