3
# Copyright 2009 Canonical Ltd.
5
# This file is part of launchpadlib.
7
# launchpadlib is free software: you can redistribute it and/or modify it
8
# under the terms of the GNU Lesser General Public License as published by the
9
# Free Software Foundation, version 3 of the License.
11
# launchpadlib is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16
# You should have received a copy of the GNU Lesser General Public License
17
# along with launchpadlib. If not, see <http://www.gnu.org/licenses/>.
19
"""A script to retrieve a Launchpad request token.
21
This script will create a Launchpad request token and print to STDOUT
22
some JSON data about the token and the available access levels.
27
from optparse import OptionParser
28
from launchpadlib.apps import RequestTokenApp
30
parser = OptionParser()
31
parser.usage = "%prog CONSUMER_NAME [-r SITE NAME] [-c CONTEXT]"
32
parser.add_option("-s", "--site", dest="web_root",
33
help=("The name of the Launchpad site to ask for a request "
34
"token (default: %default). This can also be the "
35
"URL to the root of the site."),
36
metavar="SITE", default="staging")
37
parser.add_option("-c", "--context", dest="context",
38
help="Restrict the token to a specific context "
39
"(example: firefox)", metavar="CONTEXT", default="")
41
if __name__ == '__main__':
42
(options, args) = parser.parse_args()
44
parser.error("No consumer name supplied")
45
consumer_name = args[0]
46
app = RequestTokenApp(
47
options.web_root, consumer_name, options.context)