diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt index 5a0a4168cd5..0748113711e 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationRepositoryImpl.kt @@ -32,7 +32,9 @@ class AuthenticationRepositoryImpl @Inject constructor( } override suspend fun initiateLoginFlow(): LoginFlowInit { + val url = urlRepository.getUrl()?.toHttpUrlOrNull().toString() return authenticationService.initializeLogin( + url + "auth/login_flow", LoginFlowRequest( AuthenticationService.CLIENT_ID, AuthenticationService.AUTH_CALLBACK, @@ -42,8 +44,9 @@ class AuthenticationRepositoryImpl @Inject constructor( } override suspend fun loginAuthentication(flowId: String, username: String, password: String): LoginFlowCreateEntry { + val url = urlRepository.getUrl()?.toHttpUrlOrNull().toString() return authenticationService.authenticate( - AuthenticationService.AUTHENTICATE_BASE_PATH + flowId, + url + AuthenticationService.AUTHENTICATE_BASE_PATH + flowId, LoginFlowAuthentication( AuthenticationService.CLIENT_ID, username, diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationService.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationService.kt index de96f8aabfa..fc3251f52ca 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationService.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/authentication/impl/AuthenticationService.kt @@ -51,8 +51,8 @@ interface AuthenticationService { @Field("action") action: String ) - @POST("auth/login_flow") - suspend fun initializeLogin(@Body body: LoginFlowRequest): LoginFlowInit + @POST + suspend fun initializeLogin(@Url url: String, @Body body: LoginFlowRequest): LoginFlowInit @POST suspend fun authenticate(@Url url: String, @Body body: LoginFlowAuthentication): LoginFlowCreateEntry