Skip to content

Instantly share code, notes, and snippets.

@deiu
Created July 6, 2012 11:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deiu/3059539 to your computer and use it in GitHub Desktop.
Save deiu/3059539 to your computer and use it in GitHub Desktop.
Uses a certificate (in PEM) to authenticate (through WebID) and access a protected page.
#!/usr/bin/env python
import urllib
import httplib2
cert_file = 'my.pem'
http = httplib2.Http(disable_ssl_certificate_validation=True)
http.add_certificate('', cert_file, domain='')
url = 'https://auth.my-profile.eu/auth/index.php?authreqissuer=https://my-profile.eu/index.php'
response, content = http.request(url)
headers = {'Cookie': response['set-cookie']}
newurl = 'https://my-profile.eu/test.php'
response, content = http.request(newurl, 'GET', headers=headers)
print content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment