41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
# fargo - document box
|
|
# Copyright (C) 2016-2019 Entr'ouvert
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify it
|
|
# under the terms of the GNU Affero General Public License as published
|
|
# by the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from fargo.oauth2.models import OAuth2Client
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Create an OAuth2 client'
|
|
|
|
def add_arguments(self, parser):
|
|
parser.add_argument('client_name')
|
|
parser.add_argument('redirect_uris')
|
|
parser.add_argument('--client-id', required=False, default=None)
|
|
parser.add_argument('--client-secret', required=False, default=None)
|
|
|
|
def handle(self, client_name, redirect_uris, client_id, client_secret, **options):
|
|
kwargs = {
|
|
'client_name': client_name,
|
|
'redirect_uris': redirect_uris,
|
|
}
|
|
if client_id:
|
|
kwargs['client_id'] = client_id
|
|
if client_secret:
|
|
kwargs['client_secret'] = client_secret
|
|
client = OAuth2Client.objects.create(**kwargs)
|