Skip to content

Instantly share code, notes, and snippets.

@nottrobin
Last active April 9, 2020 14:18
Show Gist options
  • Save nottrobin/8e89667066815a263021a5d3ba248e22 to your computer and use it in GitHub Desktop.
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
#! /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