snapcrafters / .github

Snapcrafters' special .github repo to apply organization-wide defaults and change the homepage
1 stars 5 forks source link

[Enhancement]: Provide a script for generating launchpad credentials separately from snapcraft #18

Open lengau opened 7 months ago

lengau commented 7 months ago

What changes would you like?

Grabbing the credentials file that snapcraft generates is mostly okay, but it would be ideal to have a script that'll generate one that:

  1. Can use a different user
  2. Isn't a system-wide consumer
  3. Has limited access

Any extra information?

It came out of this discussion on Matrix: https://matrix.to/#/!cniCqhKpzVvOBMHAVt:matrix.org/$EWg88A8PPRwiC2IBGh671MiVjvVZlYp14287woJKw04

I'm mostly filing this as a TODO for myself, but if anyone else happens to do it before I get around to it I'll be grateful :-)

lengau commented 7 months ago

This gets a basic version, but doesn't really achieve what should be in the docs:

import sys
import tempfile
from launchpadlib.launchpad import Launchpad
from launchpadlib.uris import LPNET_SERVICE_ROOT

with tempfile.NamedTemporaryFile("w+") as credentials_file:

    Launchpad.login_with(
        application_name="Snapcrafters CI",
        service_root=LPNET_SERVICE_ROOT,
        credentials_file=credentials_file.name,
        version="devel",
        consumer_name="Snapcrafters CI"
    )

    print(credentials_file.read())
soumyaDghosh commented 3 months ago

I think the tokenator is the best repo for this issue.