https://kotlinlang.org logo
#http4k
Title
# http4k
r

Rodrigo Navarro

09/23/2020, 5:02 PM
I am tring to implement an OAuth server by using http4k OAuthServer class. Every interface and method are quite clear, except the create access token one:
Copy code
fun create(
        clientId: ClientId,
        tokenRequest: AuthorizationCodeAccessTokenRequest,
        authorizationCode: AuthorizationCode
    ): Result<AccessToken, AuthorizationCodeAlreadyUsed>
I need a way to associate the access token with the authenticated user here. I was thinking that I could use the requests contexts api to pass the logged user somehow, but this method doesn’t have access the request object. I don’t know if I am not seeing something obvious here, but I can’t find a way to implement this.
s

s4nchez

09/23/2020, 7:23 PM
@Rodrigo Navarro the information about the user is usually derived from the autorization code, and the user reference is also part of the token (so it can be looked up aftewards). If you have no alternative, we could consider extending that API to allow passing the request, but would like to understand a bit more of your use case if possible.
r

Rodrigo Navarro

09/23/2020, 7:38 PM
Hey Ivan, I am so sorry, this is my first project with http4k and I was confused by how things are composed. You are totally right, the user is derived by the authorization code, so we don’t really need access to the request on the token generation endpoint.
👍 1
s

s4nchez

09/23/2020, 7:55 PM
No need to be sorry, @Rodrigo Navarro ! Please keep asking whenever you get stuck. This kind of feedback helps us to improve our APIs and our docs simple smile
r

Rodrigo Navarro

09/23/2020, 7:55 PM
Thanks a lot Ivan!
🙂 2
12 Views