Login System using javascript window.location

Hi Screen Scraper

Let me start off by thanking you guys for developing such a great product, it's helped us a lot with saving information out of a web based application that requires logging in to pull reports. The website recently changed their log in page as they are splitting up their american customers from canadian, adding a .ca domain.

I am trying to get screen scraper to work with the new login page but it's more complicated now with the cross domain redirect. The scrapable files I have set up to attempt to mirror the site's login process is as follows (unfortunately I can't give an example login because the app contains sensitive information)

-Initial Request (https://login.pointclickcare.ca)
-Login Redirect (https://login.pointclickcare.ca/userLogin.xhtml) This does not happen automatically in SS so I have another scrapable file to make the request. The old login worked similarly>
-Send Credentials (https://login.pointclickcare.ca/userLogin.xhtml) includes UN and PW parameters
-Javascript Redirect (https://www.pointclickcare.com/home/userLogin.xhtml?cd=[really long encoded parameter]) Notice the domain is now .com

The response I get from the "Send Credentials" scrapable file in the old log in screen was the home page (logged in)
What I am getting now is a blank page with some JS:

function doRedirect()
{
window.location = "https://www.pointclickcare.com/home/userLogin.xhtml?cd=[really long encoded parameter]";
}

This URL will bring up the authenticated home page even if I clear everything out of my browser and paste in the URL. I attempted to do a pattern match on CD=~@CD@~ and I am able to pull out the cd parameter and save to session, but if I try to use ~#CD#~ as the parameter for the "Javascript Redirect" scrapable file it doesn't work.

If I view the response from browser from "Send Credentials" (the one with the JS redirect) it logs me in.

Any ideas or questions to ask me for clarification? I'm stumped.

On the "Send Credentials",

On the "Send Credentials", there must be something missing. Odd are that if you go to the "last request" > "compare to proxy transaction" and point it to the request in your proxy session, there will be a difference in the headers or cookies. If you can rectify that, I bet it will take care of it.

update for those interested

The problem ended up being the parameter was being encoded once by the code that put it on the page, and then again by screen scraper. I solved the problem as follows:

session.setVariable("CD", URLDecoder.decode(session.getVariable("CD"), "UTF-8"));

CD is the parameter I am extracting out of the javascript window.location, saving it in the session, pulling it out of the session in my script and decoding it before putting it back. Then the next scrapable file uses ~#CD#~ as the parameter.

So I have the first page that is scraped once screen scraper is logged in as the first scrapable file in my scraping session. Then as a script "before file is scraped" I have the script that calls my login pages in the correct order.

import java.net.URLDecoder;

session.scrapeFile("1a. login");
session.scrapeFile("1b. login");
session.scrapeFile("1c. login"); //CD extracted from this file
session.setVariable("CD", URLDecoder.decode(session.getVariable("CD"), "UTF-8"));
session.scrapeFile("1d. home");
session.scrapeFile("1e. home");