Skip to content

Instantly share code, notes, and snippets.

@nottrobin
Last active April 9, 2020 14:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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