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
Post a Comment