Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $client = $this->clientManager->createClient();
     $client->setRedirectUris($input->getOption(self::OPTION_REDIRECT_URI));
     $client->setAllowedGrantTypes($input->getOption(self::OPTION_GRANT_TYPE));
     $this->clientManager->updateClient($client);
     $output->writeln('Client created');
     $output->writeln('client_id=' . $client->getId() . '_' . $client->getRandomId());
     $output->writeln('client_secret=' . $client->getSecret());
 }
Exemplo n.º 2
0
 /**
  * @param $redirectUrl
  * @return \WeavingTheWeb\Bundle\ApiBundle\Entity\OAuth\Client
  */
 public function make($redirectUrl)
 {
     /** @var \WeavingTheWeb\Bundle\ApiBundle\Entity\OAuth\Client $client */
     $client = $this->clientManager->createClient();
     $client->setRedirectUris(array($redirectUrl));
     $client->setAllowedGrantTypes(array('token', 'authorization_code'));
     $this->clientManager->updateClient($client);
     $authorizationUrl = $this->router->generate('fos_oauth_server_authorize', ['redirect_uri' => $redirectUrl, 'client_id' => $client->getPublicId(), 'response_type' => 'code', 'code' => '']);
     $client->setAuthorizationUrl($authorizationUrl);
     return $client;
 }