diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt index 10104cead..72fd8c755 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaApi.kt @@ -48,15 +48,10 @@ class HikkaApi( } } - suspend fun getTokenInfo(accessToken: String): HKAuthTokenInfo { + private suspend fun getTokenInfo(accessToken: String): HKAuthTokenInfo { return withIOContext { - val request = Request.Builder() - .url("${BASE_API_URL}/auth/token/info") - .header("auth", accessToken) - .get() - .build() with(json) { - client.newCall(request) + client.newCall(authTokenInfo(accessToken)) .awaitSuccess() .parseAs() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt index 6b9e92d29..886b73ac8 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/hikka/HikkaInterceptor.kt @@ -8,14 +8,13 @@ import okhttp3.Response import uy.kohesive.injekt.injectLazy class HikkaInterceptor(private val hikka: Hikka) : Interceptor { - private val json: Json by injectLazy() private var oauth: HKOAuth? = hikka.loadOAuth() override fun intercept(chain: Interceptor.Chain): Response { val originalRequest = chain.request() - val currAuth = oauth ?: throw Exception("Not authenticated with Hikka") + val currAuth = oauth ?: throw Exception("Hikka: You are not authorized") if (currAuth.isExpired()) { val refreshTokenResponse = chain.proceed(HikkaApi.refreshTokenRequest(currAuth.accessToken))