Comment 2 for bug 493506

Leonard Richardson (leonardr) wrote :

I can do a little better. These values are published by Launchpad in a JSON document when you request an access token, and launchpadlib knows how to fetch and process this document.

"To get an up-to-date list of access levels, pass
token_format=Credentials.DICT_TOKEN_FORMAT into
Credentials.get_request_token, load the dict as JSON, and look
in 'access_levels'."

I designed this for use by non-browser authentication clients, so that they would always be able to get an up-to-date list of access levels. You can see the document by running the launchpad-request-token program:

$ bin/py src/launchpadlib/bin/launchpad-request-token foobar
{"oauth_token_secret": "XXX", "access_levels": [{"value": "UNAUTHORIZED", "title": "No Access"}, {"value": "READ_PUBLIC", "title": "Read Non-Private Data"}, {"value": "WRITE_PUBLIC", "title": "Change Non-Private Data"}, {"value": "READ_PRIVATE", "title": "Read Anything"}, {"value": "WRITE_PRIVATE", "title": "Change Anything"}], "oauth_token": "XXX", "oauth_token_consumer": "foobar", "lp.context": ""}

As you can see, the document maps the constants to human-readable descriptions.

I recognize that this itself is not documented, but it's better than a hard-coded list.