authentication required 怎么解决idea控制台乱码 idea

Rate this:
I want to translate from English to Malay using Google API.
I have the following code:
public static string TranslateText(string input, string languagePair, Encoding encoding)
string url = String.Format("/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", input, languagePair);
string result = String.E
using (WebClient webClient = new WebClient())
webClient.Encoding =
NetworkCredential netcredit = new NetworkCredential("MyNetworkUserID", "MyNetworkPassword", "corp");
webClient.Credentials =
webClient.Proxy = new System.Net.WebProxy()
Credentials = new System.Net.NetworkCredential("MyNetworkUserID", "MyNetworkPassword", "corp")
result = webClient.DownloadString(url);
Match m = Regex.Match(result, "(?&=&div id=result_box dir=\"ltr\"&)(.*?)(?=&/div&)");
if (m.Success)
result = m.V
result="Failure";
After running this:Getting the following error:Unable to connect Remote Server,the detail error msg is as below:
&No connection could be made because the target machine actively refused it 209.85.231.104:80&
Where did I go wrong?Please help me.
Posted 28-Nov-10 23:01pm
Updated 29-Nov-10 2:01am
Solution 1
What happens if you don't set credentials on the webclient. It's very likely that you need the credentials for the proxy, but not for google translate. Another thing that caught my attention is that you didn't explicitely specify the proxy servers address.
Modification
Use this to create the web proxy:
WebProxy proxyObject = new WebProxy("http://nameOfYourProxyServer:80/");
proxyObject.Credentials =
new System.Net.NetworkCredential("MyNetworkUserID", "MyNetworkPassword", "corp");
You'll have to substitute the name of your proxy server in the construtor of WebProxy and I'm assuming here that port 80 is the proxy port. You'll have to ask your network administrator what name and port to use.
Posted 29-Nov-10 3:18am
Updated 29-Nov-10 19:39pm
Solution 2
Hi Manfred,
Thanks for your time and help.But unfortunately it is giving the following error:"The Remote server returned an error:407:Proxy Authentication Required!"
I am running it in IE7,and I checked in the following path:Tools-&internet Options-&Connections-&LAN Settings,and there I found that "use a proxy server for your LAN" is checked and ADdress being proxy1 and port no being 3128.
Am I missing something?
This is how my new function looks like as suggested by you:
public static string TranslateText(string input, string languagePair, Encoding encoding)
string url = String.Format("/translate_t?hl=en&ie=UTF8&text={0}&langpair={1}", input, languagePair);
string result = String.E
WebClient webClient = new WebClient();
webClient.Encoding =
NetworkCredential netcredit = new NetworkCredential("archowdhury", "Secure*45", "corp");
webClient.Credentials =
WebProxy proxyObject = new WebProxy("http://proxy1:3128/");
proxyObject.Credentials = new System.Net.NetworkCredential("archowdhury", "Secure*45", "corp");
webClient.Proxy = proxyO
result = webClient.DownloadString(url);
Match m = Regex.Match(result, "(?&=&div id=result_box dir=\"ltr\"&)(.*?)(?=&/div&)");
if (m.Success)
result = m.V
Posted 29-Nov-10 20:53pm
<button class="toolbar" onclick="InsertText('&l' + 't;');" title="Insert HTML Extended Character Code For &&&
Strip HTML
Encode HTML
Paste as-is
Code block
Quoted Text
Best guess
When answering a question please:
Read the question carefully.
Understand that English isn't everyone's first language so be lenient of bad
spelling and grammar.
If a question is poorly phrased then either ask for clarification, ignore it, or
edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
This content, along with any associated source code and files, is licensed under
Last Updated 1 Jun 2015
Copyright & ,
All Rights Reserved.
CodeProject,
503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada
+1 416-849-8900 x 100java - HTTP Error 407 Proxy authentication required - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
I am trying to access the url by using this code
System.setProperty("http.proxyHost", "111.88.15.108");
System.setProperty("http.proxyPort", "8002");
System.setProperty("http.proxyUser", "user");
System.setProperty("http.proxyPassword", "password");
URL oracle = new URL("/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputL
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
This is working fine in my window machine but this is not working in linux machine. i am getting
eror like this
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 407 for URL:
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.yahoo.Connection.main(Connection.java:31)
Even proxy settings are correct and i tried like this also
java -Dhttp.proxyHost="111.88.15.108" -Dhttp.proxyPort="8002" -Dhttp.proxyUser="user" -Dhttp.proxyPassword="password"
-jar yahoo_test3.jar
But Same Error and i tried to set the export http_proxy= in
/etc/profile but no use
Any idea where it is going wrong.
I had the same problem. The following worked for me.
Authenticator.setDefault(new Authenticator()
protected PasswordAuthentication getPasswordAuthentication()
return new PasswordAuthentication("username","password".toCharArray());
18.3k114760
The following worked for me
public class TEST4 {
public static void main(String[] args) throws IOException {
System.setProperty("http.proxyHost", "147.67.217.23");
System.setProperty("http.proxyPort", "8012");
URL url=new URL("");
URLConnection uc = url.openConnection ();
String encoded = new String (base64Encode(new String("pecador:d8kjk69t")));
uc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
uc.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String inputL
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
public static String userNamePasswordBase64(String username, String password) {
return "Basic " + base64Encode(username + ":" + password);
private final static char base64Array[] = { 'A', 'B', 'C', 'D', 'E', 'F',
'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', '+', '/' };
private static String base64Encode(String string) {
String encodedString = "";
byte bytes[] = string.getBytes();
int i = 0;
int pad = 0;
while (i & bytes.length) {
byte b1 = bytes[i++];
if (i &= bytes.length) {
b2 = bytes[i++];
if (i &= bytes.length) {
b3 = bytes[i++];
byte c1 = (byte) (b1 && 2);
byte c2 = (byte) (((b1 & 0x3) && 4) | (b2 && 4));
byte c3 = (byte) (((b2 & 0xf) && 2) | (b3 && 6));
byte c4 = (byte) (b3 & 0x3f);
encodedString += base64Array[c1];
encodedString += base64Array[c2];
switch (pad) {
encodedString += base64Array[c3];
encodedString += base64Array[c4];
encodedString += base64Array[c3];
encodedString += "=";
encodedString += "==";
return encodedS
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
The week&#39;s top questions and answers
Important community announcements
Questions that need answers
By subscribing, you agree to the
Stack Overflow works best with JavaScript enabledauthentication - Cannot auth to SVN using IntelliJ - Stack Overflow
to customize your list.
Announcing Stack Overflow Documentation
We started with Q&A. Technical documentation is next, and we need your help.
Whether you're a beginner or an experienced developer, you can contribute.
After a reinstallation of Windows XP I have a huge problem with IntelliJ and Subversion plugin.
I've added an existing project to IntelliJ, which was checkouted from SVN that needs autorisation (ssh+svn://).
During update/commit it asks me for credential. I set username and private key/passphrase but IntelliJ rejects it and ask for it again and again.
When I update/commit that project using TortoiseSVN with auth cert in Pageant loaded (putty tool), it works fine.
Same thing with other projects even checkouted after reinstallation.
How can I fix that issue ?
70.3k32151229
Make sure you are using a key in the OpenSSH format and entering the key password correctly. I've verified it with my own svn+ssh repository and it works fine.
172k29446402
Did you find this question interesting? Try our newsletter
Sign up for our newsletter and get our top new questions delivered to your inbox ().
Subscribed!
Success! Please click the link in the confirmation email to activate your subscription.
In case this helps anyone else: ensure that the username field is the same as the one used for SVN and NOT the one registered with IntelliJ.
15.4k114684
Which version of Intellij are you referring to? The one i use is 9.0.4 and I can't log into svn despite providing the right credentials. The workaround to the problem is to use the svn plugin bundled with Intellij 9.0.2. Just go to the plugins folder of the older installation, copy over the files from the folder svn4idea into the same folder of the 9.0.4 installtion.
2,88341936
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you&#39;re looking for?
Browse other questions tagged
Stack Overflow works best with JavaScript enabled

我要回帖

更多关于 idea 自动解决错误 的文章

 

随机推荐