Last active
April 9, 2020 14:18
-
-
Save nottrobin/8e89667066815a263021a5d3ba248e22 to your computer and use it in GitHub Desktop.
A proof of concept script for authenticating with security API endpoints on ubuntu.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
# Standard library | |
import os | |
from http.cookiejar import MozillaCookieJar | |
# Packages | |
from macaroonbakery import httpbakery | |
client = httpbakery.Client(cookies=MozillaCookieJar(".login")) | |
if os.path.exists(client.cookies.filename): | |
client.cookies.load(ignore_discard=True) | |
response = client.request( | |
"POST", ("http://localhost:8001/security/notices") | |
) | |
client.cookies.save(ignore_discard=True) | |
print(response, response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment