I do not want to give username/password for proxy setting I have for my office network, I could give PROXY to browser either :
String PROXY = "localhost:8080";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabailities();
cap.setPreference(CapabilityType.PROXY, proxy);
or
user_pref("network.proxy.http", "127.0.0.1");
user_pref("network.proxy.http_port", 8084);
user_pref("network.proxy.ssl", "127.0.0.1");
user_pref("network.proxy.ssl_port", 8084);
user_pref("network.proxy.no_proxies_on", "localhost:4444");
user_pref("network.proxy.type", 1);
but, what ever I do, its still asking for password for Webdriver.
Note: I could send username/password for htmlunit driver. PLEASE HELP!
Try below
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 0);
WebDriver driver = new FirefoxDriver(profile);
I have read a lot of posts stating that you have to send the profile as a base64 encoded string.
cap.setPreference(CapabilityType.PROXY, proxy.ToBase64String());
The documentation I've read hasn't ever been conclusive if this is necessary or not, but it's worth a shot.
Related
The call to the newer version of com.google.cloud.pubsub.spi.v1.Publisher.publish(pubsubMessage).get() is hanging forever. I'm not sure what the problem is.
Code snippet:
com.google.cloud.pubsub.spi.v1.Publisher publisher = Publisher.defaultBuilder(TopicName.parse("projects/" + projectId + "/topics/" + topicName))
.setChannelProvider(TopicAdminSettings
.defaultChannelProviderBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(ServiceAccountCredentials.fromStream(new FileInputStream(keyFile))))
.build())
.build();
ApiFuture<String> messageIdFuture = publisher.publish(pubsubMessage);
messageIdFuture.get() // HANGS FOREVER!!
The older API works fine where we do:
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(new NetHttpTransport())
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(serviceAccount)
.setServiceAccountScopes(Arrays.asList(PubsubScopes.PUBSUB))
.setServiceAccountPrivateKeyFromP12File(new File(keyFile))
.build();
Pubsub pusub = new Pubsub.Builder(transport, JSON_FACTORY, credential).setApplicationName("bigquery").build();
PubsubMessage pubsubMessage = new PubsubMessage();
pubsubMessage.encodeData(message.getBytes());
PublishRequest publishRequest = new PublishRequest();
publishRequest.setMessages(Arrays.asList(pubsubMessage));
pubsub.projects().topics().publish(outputTopic, publishRequest).execute();
Can somebody point out what am I missing?
This may be because you have not configured subscription for the topic or given proper permissions in the GCP console.
It is required to have a subscription attached to the topic. Also make sure you give the correct permissions in the console. Note that you give this
"client_email" : (an auto-generated email id)
auto-generated email id with admin subscriber permissions in the console.
You will get this field in your projectname.json credentials file while configuring.
Hope it helps.
I have no idea why but once i've add a compile dependency for guava no more hangs on a get call.
compile group: 'com.google.guava', name: 'guava', version: '23.0'
For us, when we removed guava dependency, it worked. We are using following version for publishing:
com.google.cloud:google-cloud-pubsub:1.33.0
I am not able to get access token from salesforce instance, Can anyone help me out from this.
I have tried many different ways, but not able to actually get it done :(.
HttpClient httpclient2 = new DefaultHttpClient();
HttpPost post = new HttpPost("https://instance.salesforce.com/services/oauth2/token");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("client_id", CONSUMER_KEY));
params.add(new BasicNameValuePair("client_secret", SECRET_KEY));
params.add(new BasicNameValuePair("grant_type", "password"));
params.add(new BasicNameValuePair("username", "emailaddress"));
params.add(new BasicNameValuePair("password", password+securityToken));
post.setEntity(new UrlEncodedFormEntity(params));
HttpResponse response = httpclient2.execute(post);
String body = EntityUtils.toString(response.getEntity());
System.out.println(body);
It is giving below error :
{"error":"invalid_grant","error_description":"authentication failure"}
Thanks in advance.
I believe that the problem is you need to use login.salesforce.com as the login host, not <instance>.salesforce.com but if that doesn't work, here is a complete example that uses httpclient to login and then make a query: https://github.com/jamesward/salesforce-rest-starter
It has over 2 days but Finally, I have done it :).
Program was correct but there was missing something with Configuration from Salesforce side. Below is the missing configuration which fixed my issue.
Thanks.
I am trying to read mail from exchange server using IMAP protocol. I have implemented the code. But following exception occurs while executing the code.This exception occurs occasionally, I didn't get the reason why this is happening.
javax.mail.MessagingException: A3 BAD User is authenticated but not connected.;
nested exception is:
com.sun.mail.iap.BadCommandException: A3 BAD User is authenticated but not connected.
at com.sun.mail.imap.IMAPFolder.open(IMAPFolder.java:958)
at agent.client.attributeGroups.SendReceive.readMailAndReply(SendReceive.java:115)
at agent.client.attributeGroups.MailQueue.calculateTime(MailQueue.java:45)
at agent.client.MainClass$1.run(MainClass.java:72)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
code:
Properties props = new Properties();
props.put("mail.imap.auth", "true");
props.put("mail.imap.ssl.enable", "true");
props.put("mail.imap.host", "outlook.office365.com");
props.put("mail.imap.port", "993");
props.put("mail.transport.protocol", "imap");
props.put("mail.imap.auth.plain.disable", true);
props.put("mail.imap.auth.ntlm.disable", true);
props.put("mail.imap.auth.gssapi.disable", true);
//Get session object by passing credentials.
Session session = Session.getDefaultInstance(props,
new javax.mail.Authenticator(){
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
mailId, mailPass);}});
//Creating IMAP store and connecting it to Mailbox using credentials.
store = session.getStore("imap");
store.connect(mailId, mailPass);
//Getting mailbox mails.
inbox = store.getFolder("INBOX");
inbox.open(Folder.READ_WRITE);
int totalMailCount = inbox.getMessageCount();
//Reading all mails to Message array.
Message[] messages = inbox.getMessages(1, totalMailCount);
for (Message mail : messages)
{
Address[] fromAddresses = mail.getFrom();
String mailFrom = fromAddresses[0].toString();
String mailSubject = mail.getSubject();
System.out.println(mailFrom);
System.out.println(mailSubject);
mail.setFlag(Flags.Flag.DELETED,true);
}
}
}
Please suggest me suggestions to resolve this exception.
I have also faced that issue
You didn't close the connection,it always in open.
If you use Store and Inbox it always authenticated but not connected
It is authentication successfully but not connected because session is paradise.
You need to add below lines to your code.
First close the inbox after read
inbox.close(true);
Next close the store Connection
store.close();
If you close the estabilished connection correctly then it will connected according to the session.
Hope this really helpful for you
My problem was because I use a process to move emails from inbox to another different folder. I did it in batches because move big quantities emails throw Timeout exception, so I try to move small cquantities and I avoid the Timeout exception but started to get the BadCommandException: A2 BAD User is authenticated but not connected Exception. So I looking by an amount that worked for me. I got the idea base on this post
https://github.com/mscdex/node-imap/issues/689
It is a Microsoft's mechanism to shut down chatty clients. The
solution would be to login to this account less frequently.
It is due to a bug in the IMAP implementation. If the client presents a valid user name but an invalid password, the server
accepts the login, but subsequent commands fail with the
aforementioned error message.
It is a shared mailbox and you are using incorrect login scheme. Use Username#DomainName\SharedMailboxAlias for O365
This error message appears to be triggered when you've connected to an Exchange mail server (such as Office365) with a valid user and the correct password, but that user doesn't have permissions for the type of connection you made.
For example, I've seen several cases now where an IMAP connection was made, the system logged in with valid credentials, and the moment the first IMAP command was sent, the server said, "User is authenticated but not connected" and closed the connection.
To correct it, we went into the Exchange server or Office365 mail settings and ensured that the IMAP permission was checked for that user.
First,you should check the mail.imap.host value is equivalent to the email address's server.
If you use outlook OC
If true,you could then try to change the protocol to IMAPS
I hope the snippets that set of properties can help many that want to recieve mails.
sysProperties.put("mail.imap.starttls.enable", true);
MailSSLSocketFactory sf = null;
try {
sf = new MailSSLSocketFactory();
} catch (GeneralSecurityException e1) {
e1.printStackTrace();
}
sf.setTrustAllHosts(true);
sysProperties.setProperty("mail.imaps.auth.plain.disable", "true");
sysProperties.setProperty("mail.imaps.auth.ntlm.disable", "true");
sysProperties.put("mail.imap.ssl.socketFactory", sf);
sysProperties.setProperty("mail.imap.port", instance.getConfigPropertiesValue(configProperties, "mail.imap.port"));
sysProperties.setProperty("mail.imap.ssl.socketFactory.port", "993");
Session session = Session.getDefaultInstance(sysProperties, null);
Store store = null;
store = session.getStore("imaps");
store.connect("mail.serverhost", "mail.serverport"), "mail.username,"mail.password"));
Could it be related to your exchange settings? I ran into this error with imap and outlook.office365.com. I tried to set up the same account in Outlook to make sure it was working in general. Although I was able to add the account, when I actually tried to look at the inbox Outlook became unresponsive. So in my case, it was a problem with the account in general, not with how I was trying to connect.
It appears to be a bug in the office365 server. It's telling you that your password was wrong.
I am currently using a Get Request with proxy information:
String result1 = Request.Get("_http://somehost/")
.version(HttpVersion.HTTP_1_1)
.connectTimeout(1000)
.socketTimeout(1000)
.viaProxy(new HttpHost("myproxy", 8080))
.execute().returnContent().asString();
The result is a "Proxy Authentication Required" error. I believe a username and password is required from the server making the request? If so, how do I add that detail? I have never used the Fluent API before.
Here is an example using the Fluent API. The executor can be used to specify credentials for the proxy.
HttpHost proxyHost = new HttpHost("myproxy", 8080);
Executor executor = Executor.newInstance()
.auth(proxyHost, "username", "password");
String result1 = executor.execute(Request.Get("_http://somehost/")
.viaProxy(proxyHost))
.returnContent()
.asString();
You need a CredentialsProvider.
final CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(new AuthScope(proxy), new UsernamePasswordCredentials(username, password));
final HttpPost httppost = new HttpPost(uri);
httppost.setConfig(RequestConfig.custom().setProxy(proxy).build());
String line = HttpClientBuilder.create().setDefaultCredentialsProvider(credsProvider).build() .execute(httppost).getStatusLine());
Also, there was a bug in 4.3.1 that impacted authentication. It is fixed in 4.3.2.
https://issues.apache.org/jira/browse/HTTPCLIENT-1435
Executor executor = Executor.newInstance()
.auth(new HttpHost("myproxy", 8080), "username", "password")
.authPreemptive(new HttpHost("myproxy", 8080));
Response response = executor.execute(<your reques>);
I am trying to connect to D3 Database with MVSP java api. So far:
I have downloaded the mvapi.jar
added it in project lib folder
written the sample code for connection inside main method
String url = "jdbc:mv:d3:hostname:portNo";
Properties props = new Properties();
props.setProperty("username", "");
props.setProperty("password", "");
String account = "AGCO";
String password = "";
MVConnection connection = null;
try {
// Getting error at this point
connection = new MVConnection(url,props);
MVStatement mvStatement = connection.createStatement();
connection.logTo(account,password);
MVResultSet results = mvStatement.executeQuery(query);
}
com.tigr.mvapi.exceptions.MVException: server error with errorCode 1023.
I checked the console but I'm not able to figure out the actual cause or whether I am entering the wrong username, password.
Please suggest what I am doing wrong.
First, you have to set a breakpoint or trace which function is throwing the errors. Then check the routes, (FileName) probably you will have much more experience than I do, but keep in mind that giving the full route ("account,filename," where the last comma is important) is never a bad idea while keep you safer and is mandatory if the filename is in a different account that you are logged to.
And like always please verify these things:
You have enough licenses. Try to close any terminal you have opened for testing your queries. Yes you know is true. One connection one license. Sometimes MVSP let you two under the same IP but chek this.
MVSP service is running. See Pick D3 documentation.
Your USER and ACCOUNT are both ENABLED to access in the MVSP server otherwise you won't be able to access these files or login with the user through the API. See the documentation to enable in the MVSP.Menu account.
I hope this helps.