|
@@ -0,0 +1,39 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace Base\OAuthBundle\Command;
|
|
|
+
|
|
|
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
|
+use Symfony\Component\Console\Input\InputInterface;
|
|
|
+use Symfony\Component\Console\Output\OutputInterface;
|
|
|
+
|
|
|
+class CreateOAuthClientCommand extends ContainerAwareCommand
|
|
|
+{
|
|
|
+
|
|
|
+ protected function configure()
|
|
|
+ {
|
|
|
+ $this
|
|
|
+ ->setName('oauth:client:create')
|
|
|
+ ->setDescription('Create OAuht client')
|
|
|
+ ->setHelp('This command allows you to create an OAuth client')
|
|
|
+ ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param InputInterface $input
|
|
|
+ * @param OutputInterface $output
|
|
|
+ */
|
|
|
+ protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
+ {
|
|
|
+ $clientManager = $this->getContainer()->get('fos_oauth_server.client_manager.default');
|
|
|
+
|
|
|
+ $client = $clientManager->createClient();
|
|
|
+ $client->setRedirectUris(array('http://127.0.0.1'));
|
|
|
+ $client->setAllowedGrantTypes(array('password', 'token', 'authorization_code'));
|
|
|
+ $clientManager->updateClient($client);
|
|
|
+
|
|
|
+ $output->writeln('OAuth client successfully generated!');
|
|
|
+ $output->writeln('<info>client_id:</info> '.$client->getPublicId());
|
|
|
+ $output->writeln('<info>client_secret:</info> '.$client->getSecret());
|
|
|
+ }
|
|
|
+
|
|
|
+}
|