The following is what I think happens when you try to log into your UpassBC profile.
-
Select Simon Fraser University
-
Redirect to SFU login page
-
SFU automatically authorizes UpassBC app
-
Redirect to UpassBC callback page with access token
After this point the UpassBC page can access your information by providing the token to SFU CAS.
This script follows this path to reload your Compass card every month.
For this automator to work you need to have the following installed:
-
Ruby
-
RubyGems (Comes with Ruby by default)
Run the following command in terminal or CMD to install all the dependencies (If you do not have bundler installed run: gem install bundler):
cd ~/path_to_directory/upassbc
bundle install
*Windows users see Windows section below
Enter your SFU Computing ID and Password instead of the place holders in the auth.json file.
{
"username": "davida",
"password": "1234abcd"
}
Run the following to schedule a Cron job
crontab -e
When the editor opens copy the following line and save it. This would schedule the script to run at 3:30pm everyday
30 15 * * * ruby /path_to_directory/upassbc/automator.rb
Edit the runAutomator.sh file -> Replace with the full path to the upassbc folder
Edit the upassbc_launchagent.plist file -> Replace {DirName} inside ProgramArguments key with the full path to the runAutomator.sh file
Make sure the full path is accessible by the root. Do NOT use the '~/Desktop/...' but use the full path '/Users/{username}/Desktop/...'
runAutomator.sh must be owned by root:
sudo chown root ./runAutomator.sh
sudo chmod 755 ./runAutomator.sh
Move the launch agent to ~/Library/LaunchAgents to run as a User Agent:
cp upassbc_launchagent.plist ~/Library/LaunchAgents/
The launch agent must be owned by root
As mentioned on Stack Exchange by diimdeep
sudo chmod 600 ~/Library/LaunchAgents/upassbc_launchagent.plist
sudo chown root ~/Library/LaunchAgents/upassbc_launchagent.plist
Register the launch file:
sudo launchctl load -w ~/Library/LaunchAgents/upassbc_launchagent.plist
The script will be run once as soon as the Launch Agent is loaded. If you don't see a logfile in the directory, something has gone wrong. If that happens try logging in as root and manually running runAutomator.sh file
IMPORTANT - There are issues with using Mechanize to open secure SSL URLs. To bypass this, SSL verification has been set to none. This shouldn't be a problem as the URLs are hardcoded in the script but it's important to relay this information.
If you recieve error while installing bundles such as " gem requires installed build tools", follow the instructions below as explained by Massimo Fazzolari on Stack Exchange
Download DevKit file from rubyinstaller.org for your particular ruby version
Extract DevKit to path C:\Ruby<Ver>\DevKit
Run cd C:\Ruby<Ver>\DevKit
Run ruby dk.rb init
Run ruby dk.rb review
Run ruby dk.rb install
Nokogiri doesn't support Ruby 2.2 and up on Windows yet. To make it work, download Nokogiri 1.6.6.2 (x64) or Nokogiri 1.6.6.2 (x86) and do the following
gem uninstall nokogiri
gem install --local <Nokogiri Download Directory>
Windows scheduler can be used to schedule the running of the script. To set up scheduler, do the following steps:
-
Google how to create a new task using task scheduler.
-
When setting an action for the task, set the following:
Program/script -> runAutomatorWindows.bat
Start in (optional) -> Directory of the script
The automator.rb script only makes a request on your behalf to upassbc website to register for all the possible months available. To increase the probability of successful update, this setup configures your system to execute the script multiple times.
The following docs were used in developing this automator