Android OkHttp with Basic Authentication

后端 未结 12 1540
感动是毒
感动是毒 2020-12-07 12:58

I\'m using the OkHttp library for a new project and am impressed with its ease of use. I now have a need to use Basic Authentication. Unfortunately, there is a dearth of w

12条回答
  •  执笔经年
    2020-12-07 13:50

    I noticed on Android with some server APIs like django you should add a word in token

    Request request = new Request.Builder()
        .url(theUrl)
        .header("Authorization", "Token 6utt8gglitylhylhlfkghriyiuy4fv76876d68")
        .build();
    

    , where that problematic word is that "Token ". Overall you should carefully see rules of those specific server APIs about how to compose requests.

提交回复
热议问题