Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@grapeot grapeot commented Jul 31, 2012

Depends on requests,

pip install requests

before running.

@whhsw

This comment has been minimized.

Copy link

@whhsw 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