https://kotlinlang.org logo
#ktor
Title
# ktor
q

Qwibbler

12/12/2023, 12:37 AM
Ktor Login Function.kt
a

Aleksei Tirman [JB]

12/12/2023, 8:16 AM
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

Qwibbler

12/12/2023, 10:45 AM
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

Aleksei Tirman [JB]

12/12/2023, 2:57 PM
You can try returning the token in response body instead of in the header.