I'm using cURLpp to send requests from a desktop client to a server, which typically responds with some json element. I can then parse that element for the information I need and display it to my users without incident. This server, however, typically deals only with requests from websites, and so in one instance the server requires interaction from the user, then performs a redirect to a webpage and sends a token I need in the url fragment. Typically I would retrieve this token using something like var Token = window.location.hash.substring(1);
on the callback page. Can curlpp be used to retrieve the url with the token? If not how can I send it to my application?
Asked
Active
Viewed 218 times
0

event44
- 630
- 5
- 17
-
Nope, you'd have to spawn a web browser, then redirect the user to the page and somehow retrieve the location back out of the web browser. – slugonamission Sep 17 '12 at 22:10
-
@slugonamission That is just not true, cumbersome, and pointless. If a user interaction in a web page generates a server request, then cUURL should be able to emulate the same request. The biggest problem is when the user interaction triggers some computations in Javascript code in order to determine the request URL, in which case it's still doable, but it involves more work. – Mihai Todor Sep 17 '12 at 22:50
-
@MihaiTodor - I'm assuming this is OAuth or similar, in which case, no, you can't perform the login to the user's account without spawning a web browser and asking them to click the accept button. – slugonamission Sep 18 '12 at 06:59
-
I think we need more details here, it's not clear what you are trying to do. Most likely you will need to follow the 302 redirect, donwload the webpage, fake up the user interaction (http post / get), extract the token from the result (libxml perhaps to parse the webpage?) and then use the token for whatever step is next.... but like I said, detail is key here. – jmc Sep 18 '12 at 09:21
-
@slugonamission OK, yeah, you have a point, but let's assume that is not the case :) – Mihai Todor Sep 18 '12 at 11:51
-
@MahaiTodor - My plan now is to have my app fork to a web browser and open the login page. I'll get the login page to redirect to a page I own, then have that page save the token as a cookie. My app will be polling for said cookie, and once detected store the key and kill the browser. – event44 Sep 19 '12 at 13:12