oligazar
11/23/2017 - 2:38 AM

Authentication, Authorization

  • Basic Auth with Retrofit2
fun authHeader(): String {
    val base = "$userName:$password"
    return "Basic ${Base64.encodeToString(base.toByteArray(), Base64.NO_WRAP)}"
}
// 2. товары для Home экрана
    @GET("wc/v2/products")
    fun getCategoryProducts(@Header("Authorization") auth: String, 
    @Query("category") categoryId: Int): Single<ArrayList<Product>>