Created
March 11, 2019 12:31
-
-
Save DjakaTechnology/3bd363ba4f95369dd5e107fdaef8c74f 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
private fun getRetrofit(c: Context): Retrofit { | |
val pref = c.getSharedPreferences(SharedKey.Session.SESSION, MODE_PRIVATE) | |
val client = OkHttpClient.Builder().addInterceptor { chain -> | |
val newRequest = chain.request().newBuilder() | |
.addHeader("Authorization", "Bearer " + pref.getString(SharedKey.Session.TOKEN, "")!!) | |
.build() | |
chain.proceed(newRequest) | |
}.build() | |
return Retrofit.Builder().baseUrl(baseUrl).client(client).addConverterFactory( | |
ScalarsConverterFactory.create()) | |
.addConverterFactory(GsonConverterFactory.create()) | |
.addCallAdapterFactory(CoroutineCallAdapterFactory()) | |
.build() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment