I am tring to implement an OAuth server by using h...
# http4k
r
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
@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
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
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
Thanks a lot Ivan!
🙂 2