android使用HttpGet进行BASIC认证

//认证URL
        HttpGet httpGet = new HttpGet(url);
        String userName = "username";
        String password = "password";
        byte[] encodedPassword = (userName + ":" + password).getBytes();
        BASE64Encoder encoder = new BASE64Encoder();
        httpGet.addHeader("Authorization","Basic "+encoder.encode(encodedPassword));

android调用HTTP接口时,要求进行BASIC认证,以上是HttpGet进行BASIC认证的代码

你可能感兴趣的:(android使用HttpGet进行BASIC认证)