12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- <?php
- namespace Base\OAuthServerBundle\Command;
- use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- use Symfony\Component\Console\Input\InputOption;
- class OAuthClientCreateCommand extends ContainerAwareCommand
- {
- protected function configure()
- {
- $this
- ->setName('oauth:client:create')
- ->setDescription('Create OAuht client')
- ->setHelp('This command allows you to create an OAuth client')
- ->addOption(
- 'redirect_uri',
- 'r',
- InputOption::VALUE_REQUIRED,
- 'OAuth Redirect URI',
- 'http://127.0.0.1/ftth/app_dev.php/login_check'
- );
- }
- /**
- * @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($input->getOption('redirect_uri')));
- $client->setAllowedGrantTypes(array('password', 'refresh_token', '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());
- }
- }
|