Skip to content

Instantly share code, notes, and snippets.

@harmittaa
Created July 13, 2019 16:48
Show Gist options
  • Save harmittaa/781a509dd066142979d04d446bde3e4d to your computer and use it in GitHub Desktop.
Save harmittaa/781a509dd066142979d04d446bde3e4d to your computer and use it in GitHub Desktop.
Koin 2.0 and Retrofit 2.6.0 example
import okhttp3.Interceptor
import okhttp3.Response
class AuthInterceptor() : Interceptor {
override fun intercept(chain: Interceptor.Chain): Response {
var req = chain.request()
// DONT INCLUDE API KEYS IN YOUR SOURCE CODE
val url = req.url().newBuilder().addQueryParameter("APPID", "your_key_here").build()
req = req.newBuilder().url(url).build()
return chain.proceed(req)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment