add timeout to OAuth2 requests

This commit is contained in:
Sebastian Stenzel
2023-10-20 12:03:07 +02:00
parent 3071410a22
commit 174225c60e
3 changed files with 7 additions and 7 deletions

View File

@@ -36,11 +36,11 @@ class AuthFlowTask extends Task<String> {
protected String call() throws IOException, InterruptedException {
var response = TinyOAuth2.client(hubConfig.clientId) //
.withTokenEndpoint(URI.create(hubConfig.tokenEndpoint)) //
.withRequestTimeout(Duration.ofSeconds(10)) //
.authFlow(URI.create(hubConfig.authEndpoint)) //
.setSuccessResponse(Response.redirect(URI.create(hubConfig.authSuccessUrl + "&device=" + authFlowContext.deviceId()))) //
.setErrorResponse(Response.redirect(URI.create(hubConfig.authErrorUrl + "&device=" + authFlowContext.deviceId()))) //
.authorize(HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(3)).build(),
redirectUriConsumer);
.authorize(redirectUriConsumer);
if (response.statusCode() != 200) {
throw new NotOkResponseException("Authorization returned status code " + response.statusCode());
}