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

Aleksandr Ivanov

07/09/2021, 12:50 PM
I’m trying to use new Bearer based authorisation https://ktor.io/docs/auth.html#bearer. Wondering why we need to have
refreshToken
in
BearerTokens
. I don’t found an usage inside library. In my case I’m storing and refreshing tokens on application side.
💯 1
a

Aleksei Tirman [JB]

07/09/2021, 2:05 PM
The
refreshTokens
lambda indirectly used here when a server responds with
401 Unauthorized
status code.
a

Aleksandr Ivanov

07/09/2021, 2:08 PM
Yes, it is how it is used, but I’m talking about field in
BearerTokens
object returned from lambda, not lambda itself.
Copy code
public class BearerTokens(
    public val accessToken: String,
    public val refreshToken: String
)
a

Aleksei Tirman [JB]

07/09/2021, 2:20 PM
This is made for convenient retrieval of a refresh token after it has been loaded with a
loadTokens
or
refreshTokens
lambda.
There are no usages because the whole object is saved.
a

Aleksandr Ivanov

07/09/2021, 2:23 PM
So, it is just to store refreshToken for future. to take it inside
refreshTokens
lambda and make an request for new accessToken.
a

Aleksei Tirman [JB]

07/09/2021, 4:44 PM
Yes, except that there is no access to a
BearerTokens
 instance inside
refreshTokens
lambda.
a

Aleksandr Ivanov

07/09/2021, 4:45 PM
So, what the reason then? 🙂
a

Aleksei Tirman [JB]

07/09/2021, 4:46 PM
I don't know. @e5l, please explain.
a

Aleksandr Ivanov

07/23/2021, 10:11 AM
Hey, @e5l, Could you provide an idea why do we need to return BearerTokens with
refrestToken
field if it is not used and can’t be retrieved back.
👀 2
e

e5l

07/23/2021, 10:15 AM
Yep, It looks like the origin intention was not clearly implemented
We should either remove
BearerToken
or pass it to the
refreshToken
lambda
🙇 1
@Aleksei Tirman [JB], could you file an issue about API cleanup?
a

Aleksandr Ivanov

07/23/2021, 10:17 AM
👍 Thanks. Would be great, because now it is confusing when you start to work with it.
a

Aleksei Tirman [JB]

07/23/2021, 10:38 AM
4 Views