RestFB: Facebook HTTP 400 error not specific enough - java

I'm using RestFB in order to connect our online photo sharing app to Facebook. But sometimes, Facebook is simply returning HTTP 400 errors to some queries. After investigation, the reasons can vary (number of posts on the wall limit reached, access token invalidated by user or even response time to long), but fact is: I don't know how to catch which error happened. That's a real issue, because obviously, the processing should not be the same: if the access token is invalidated, I would like to prompt the user in order to let him accept the application again, but if the FB plateform is simply unresponsive, I could for example try again after some time.
Any clue?

I'm Mark Allen (RestFB maintainer). Version 1.6 should address this bug.

Related

Selenium script stopes after some time

I have a selenium script that runs fine but when I am executing the same script in loop it stops after some time (1 to 2 hours).
Following is the error:
INFO: ERROR in Record- session d5609515-432f-4b01-b93d-b3b5571e009d does not exist
Kindly help me.
It's seems that in that process you have time that the page not changing and the session expires, for example in bank account's sites if there is no action on page it will kill your session after x seconds.
keep always focus on the website even if you processing other thing's
Exception: ERROR in Record- session
d5609515-432f-4b01-b93d-b3b5571e009d does not exist
tells you that you trying to use driver for any propose with session identification that not exist expired, for what i know it's session timeout
one more important thing if you have to do your script for (1 to 2 hours) you need to think about ways to split it for better results, it's internet and it's not always stable.
Session Has Expired error on the Internet
ErrorWhen browsing a website that is database driven, requires a
login, or is secured, you may see a "Session Expired" or "Session Has
Expired" error. The causes of these error messages are detailed in the
following sections.
Inactivity - If you have not been doing anything on the page for a set length of time (often 10-30min) the server will time out your
session. This is often done for security reasons and to help increase
the overall speed of the web page. In other words if you were browsing
the page and get up and leave, go to lunch, or start browsing other
pages when you come back you need to re-login and create a new
session.
Date or time not correct - Make sure the date and time are properly set on your computer.
Cookies - If you are browsing anonymously or your browser does not have cookies enabled it causes many sessions to fail. Make sure your
Internet cookies are enabled.
Firewall or proxy - If you are connecting to the Internet behind a firewall or through a proxy the firewall or proxy may be restricting
or prohibiting the session from being established.
Other site related issue - If this issue is only occurring on a certain site and you're not encountering any of the above-related
issues it's possible that it could be the site encountering an issue.
Contact the company or Webmaster to verify the problem is not on their
end.

google app engine java basic authentication

I have started to write a webApp in Eclipse where ECMAScript6 on the client (testing mostly on chrome on Win7) communicates with the server side written in Java7 on Jetty+GAEplugin via xmlHttpRequest (1 get request, user edits data, 1 post requests ). if it gets more I will move to webSockets).
The client code does not know anything about logins and provides neither user name nor password because as I understand, the browser and the user handle that. On the server side I response with 401 if basic authentication is missing.
But when testing, the browser does not ask the user for any password and does not send a second request (FF the same effect). No errors. Chrome development console claims that my
response.addHeader("WWW-Authenticate","Basic realm=\"bus driver\"");
did not reach it.
A subset of my targeted user baser does not have a google account nor FB nor twitter. So OpenId nor OAuth are of no use for that subset. OAuth doc says: " The user signs in using her Google account, .." . Any way I try to search, directs me to ways to store user data, but I have problems with the communication between browser and servlet.
I have read that I should edit web.xml, but I cannot see how to plug my home-built authentication into that. Web.xml would be okay for me because there will be about 3 pages sharing the same (*3roles=9pages).
My software should be up to date. Oracle claims that I should stop using Java 7, but I cannot get local GAE to run on Java 8 ...
Just testing on FF and looking for stupid errors I may have made last night. FF claims: InvalidStateError: An aatempt was made to use an object that is not, or is no longer, usable. Hmm seems that there is at least something wrong with my XMLhttpRequest (it worked in chrome at least without authentication). I could test GET with authentication but without ECMAscript... Still my main question remains, where is the example with old school authentication on the new kid, the cloud?
Logcat is empty. I have seen the logs getting filled in TomCat or for Android. I may have to dig into this.

how to figure out captive portal URL in java

I am trying to update an app that I wrote for Android that will automatically log a user into a captive portal at my university. The app worked fine last year with the portal URL hard coded in, however this year that won't work because they changed the server URL, I know what the URL is, so I simply changed it in my program ... which sort of works
There are two main problems, for me, with this approach.
hard coding is a pain in the ass to do every year, I also want to be able to make it future proof, so that hard coding the URL won't be necessary
for some unexplainable reason there are actually buildings on campus that will direct to the OLD authentication server, it truly boggles my mind why it would do that
I would like to be able to make an HTTP request and get the URL of the captive portal that is redirected to, how is that done?
Captive portals generally will intercept users' HTTP requests and issue a "fake" redirect to the portal's authentication page. Or they can simply replace the actual response with the login page.
If yours is a redirect-to-login, then simply do something like trying to load http://google.com, which can reasonably be expected to be truly available for at least the next few years. If the response comes in as a redirect to some totally different site, the redirect url is highly likely to be the portal's login page.
If it's a replace-the-response-with-login, then you should try to contact a known page with some known content, and see what you get back. if the response you got doesn't match you should have gotten, then you've gotten the login page and can try tearing apart the response and finding the login form via DOM operations.
Captivate portals uses 2 methods.
as described above. http redirect so the gateway takes you to another address.
ICMP - sending "better route" message
Still from my exprience on cases where non simple redirect happens the approach of expecting the redirect won't work.

Why does a 403 error suddenly occurs?

I'm using Spring Social to get some informations via the LinkedIn API. Everything works fine : I can connect to my application using LinkedIn, I can recover some granted informations about my connections...
However, sometimes, I can't access anymore to LinkedIn and get this error :
16:28:00,741 WARN [RestTemplate] GET request for "https://api.linkedin.com/v1/people/id=FNXqbb779g:(id,first-name,last-name,headline,location,industry,distance,relation-to-viewer,current-share,num-connections,num-connections-capped,summary,specialties,proposal-comments,associations,honors,interests,positions,publications,patents,languages,skills,certifications,educations,three-current-positions,three-past-positions,num-recommenders,recommendations-received,phone-numbers,im-accounts,twitter-accounts,date-of-birth,main-address,member-url-resources,picture-url,site-standard-profile-request:(url),api-public-profile-request:(url),site-public-profile-request:(url),api-standard-profile-request,public-profile-url)?format=json" resulted in 403 (Forbidden); invoking error handler
According to the error message, I'm not authorized to get the required informations (despite the fact that one minute before, I could access them).
Any ideas why ?
It seems that either your session token is getting expired or you're probably running into throttle limits. A session token is valid for some duration, you may need to check logs and see whether you are getting something like
"Your session has expired and the post data is lost. Please
re-authenticate and re-post the data"
Also check about throttle limits here:
https://developer-programs.linkedin.com/documents/throttle-limits

Too many redirects occurred trying to load URL <-- there aren't any redirects

Code:
Jsoup.connect("http://www.warriorforum.com/").followRedirects(true).get();
Log cat error:
10-14 11:58:08.593: ERROR/MY(24780): TRY1: download failed java.io.IOException: Too many redirects occurred trying to load URL http://www.warriorforum.com/
As you can see in Jsoup Connection class the exception is thrown in private Response(Response previousResponse) throws IOException when redirect count exceeds private static final int MAX_REDIRECTS = 20;
Worked about 12h ago fine, but something has changed on the host side and I can't figure out what. When viewing the url with browser, there doesn't seem to be any redirects. What is causing this error?
EDIT - accessing subforums and topics with Jsoup.connect(url).get() is working, but not the main page.
If I open the URL in my browser (Chrome), I get "This webpage has a redirect loop". It responds with a 301 and the very same URL as the new Location (http://www.warriorforum.com/).
Maybe the website is still cached in the browser? Maybe the redirect depends on client specifics (like language, country, browser, ...)?
Use WireShark to take a snapshot/trace of when it happens, then you can send it to the admins of the site for them to debug.
I had the same issue and as all ways I came to source to figure it out.
So reading others complain about similar issues I've figure it out (smart ass) and here it is for anyone likes too many opinions.
As the issue is clearly a loop issue, it has to do with the web site request and your browser's cache (authentication session perhaps).
In my case there was no internal (website ) router (rewrites or similar case) and solve it by scale the request. Otherwise a clean browsers cache might solve the issue otherwise clean all cookies (session) that related to this domain. Doesn't heart to check with other browsers if available. If different browsers have the same issue and your cache is clean (as...) and the web page request is clean (headers POST/GET/PUT ctr) then it's out of your hands. Give it up.
Check an other web page. It's a vast field out there.
P.S. Good morning stackoverflowers !!!

Categories