Android 使用OKHttp3请求接口401,返回Authorization Required错误解决

OkHttpUtils
                .get()
                .url(FORUMS)
                .addHeader("Authorization", credential)
                .build()
                .execute(new StringCallback()
                {
                    @Override
                    public void onError(Call call, Exception e, int id) {
                        Log.i(TAG, "onError: "+e.toString());
                    }

                    @Override
                    public void onResponse(String response, int id) {
                        Log.i(TAG, "onResponse: "+response);
                    }


                });
 String credential = Credentials.basic("userName", "passWord");


你可能感兴趣的:(android)