Fix dumb mistake with google sign in.
This commit is contained in:
parent
1e58752008
commit
4b5893cf43
7 changed files with 67 additions and 43 deletions
|
|
@ -1,26 +1,38 @@
|
|||
package com.pixelized.biblib.network.client
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.pixelized.biblib.utils.injection.inject
|
||||
import com.pixelized.biblib.network.client.IBibLibClient.Companion.BASE_URL
|
||||
import com.pixelized.biblib.utils.injection.inject
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.gson.GsonConverterFactory
|
||||
|
||||
|
||||
class BibLibClient : IBibLibClient {
|
||||
private val gson by inject<Gson>()
|
||||
private val interceptor = BearerInterceptor()
|
||||
private val bearerInterceptor = BearerInterceptor()
|
||||
private val httpInterceptor = HttpLoggingInterceptor().apply {
|
||||
this.level = HttpLoggingInterceptor.Level.BODY
|
||||
}
|
||||
private val retrofit: Retrofit = Retrofit.Builder()
|
||||
.addConverterFactory(GsonConverterFactory.create(gson))
|
||||
.client(OkHttpClient.Builder().addInterceptor(interceptor).build())
|
||||
.client(
|
||||
OkHttpClient.Builder()
|
||||
.addInterceptor(bearerInterceptor)
|
||||
.addInterceptor(httpInterceptor)
|
||||
.build()
|
||||
)
|
||||
.baseUrl(BASE_URL)
|
||||
.build()
|
||||
|
||||
override val service: IBibLibWebServiceAPI = retrofit.create(IBibLibWebServiceAPI::class.java)
|
||||
|
||||
override var token: String?
|
||||
get() = interceptor.token
|
||||
set(value) { interceptor.token = value }
|
||||
get() = bearerInterceptor.token
|
||||
set(value) {
|
||||
bearerInterceptor.token = value
|
||||
}
|
||||
|
||||
// endregion
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue