Skip to content

Instantly share code, notes, and snippets.

@grapeot
Created July 31, 2012 19:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grapeot/3219601 to your computer and use it in GitHub Desktop.
Save grapeot/3219601 to your computer and use it in GitHub Desktop.
Auto login script for CMU blackboard
import requests
import re
# Initial request for blackboard
r = requests.get('http://blackboard.andrew.cmu.edu/')
# Authenticaton
payload = { 'j_username' : '<your username>', 'j_password' : '<your password>', 'j_continue' : '1', 'submit' : 'Login' }
r2 = requests.post(r.url, data=payload, cookies=r.cookies)
# Manually proceed with the form
url = 'https://blackboard.andrew.cmu.edu/Shibboleth.sso/SAML2/POST'
relayState = str(re.search('name="RelayState" value="(.*)"', r2.text).group(1)).replace('&#x3a;', ':')
samlResponse = str(re.search('name="SAMLResponse" value="(.*)"', r2.text).group(1))
r3 = requests.post(url, data={'RelayState': relayState, 'SAMLResponse': samlResponse}, cookies=r2.cookies)
@grapeot
Copy link
Author

grapeot commented Jul 31, 2012

Depends on requests,

pip install requests

before running.

@whhsw
Copy link

whhsw commented Aug 1, 2012

r4 = requests.post(url, data={'action': 'refreshAjaxModule', 'modId': '_4_1','tabId':'_1_1','tab_tab_group_id':'_1_1','RelayState': relayState, 'SAMLResponse': samlResponse}, cookies=r3.cookies, verify=False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment