Last active
January 11, 2020 22:59
-
-
Save brunapereira/bd798786e83cd70c93dc85b0ab83d591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component | |
class AuthenticationGateway(private val properties: AuthenticationProperties [1]) : MicroserviceGateway() [2] { | |
override var webClient: WebClient = ClientBuilder() [3] | |
.withBaseUrl(properties.baseUrl) | |
.withFailOnUnknownProperty(false) | |
.withNamingStrategy(PropertyNamingStrategy.SNAKE_CASE) | |
.build() | |
fun authenticate(): AuthenticationToken [4] { | |
val request = | |
AuthenticationRequestBody( | |
properties.username, | |
properties.password, | |
"password" | |
) | |
val headers = mapOf("Accept-Version" to "v1") | |
return post("/tokens", request, headers, AuthenticationToken::class) [5] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment