Ktor Login Function.kt
# ktor
q
Ktor Login Function.kt
a
In what form is the token returned from the
$backend/users/sign_in
endpoint? As I can see from your code, you are getting the Authorization header, but it's a request header, not a response one. Also, the browser doesn't allow direct access to the response headers for security reasons.
q
Warning: this is my first time doing something like this and I don't exactly understand what I'm doing. I would be grateful for whatever guidance you can give me. When I send the login request, my browser shows the response headers to have
Authorization: Bearer eyJhb...
as well as the
Set-Cookie: _backend_session=%2F1vT...
My request headers don't have anything of the sort. My logger shows:
Copy code
HttpClient: REQUEST: <http://localhost:3000/users/sign_in>
METHOD: HttpMethod(value=POST)
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Access-Control-Allow-Origin: *
CONTENT HEADERS
-> Content-Length: 48
-> Content-Type: application/json console.kt:78:16

HttpClient: RESPONSE: 200 OK
METHOD: HttpMethod(value=POST)
FROM: <http://localhost:3000/users/sign_in>
COMMON HEADERS
-> cache-control: max-age=0, private, must-revalidate
-> content-type: application/json; charset=utf-8 console.kt:78:16
a
You can try returning the token in response body instead of in the header.