java - Equivalent of HTTPBasicAuth (python) in OkHttp (Android) -


i need auth key: auth = requests.auth.httpbasicauth(client_id, client_secret) code in python. how can in java (i use okhttp android app).

with okhttp can create authenticator on okhttpclient such

okhttpclient myokhttpclient = new okhttpclient(); myokhttpclient.setauthenticator(new authenticator() {         @override         public request authenticate(proxy proxy, response response) throws ioexception {             string credential = credentials.basic("username", "password");             return response.request().newbuilder().header("authorization", credential).build();         }          @override         public request authenticateproxy(proxy proxy, response response) throws ioexception {             return null;         }     }); 

this should job. found there not documentation around using basic authentication found from: android okhttp basic authentication


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -