コード例 #1
0
 /**
  * Create a new client entity.
  * 
  * @return void
  */
 protected function createClientEntity()
 {
     $id = Token::make();
     $secret = Token::make();
     $redirectUris = [];
     $id = $this->ask('New client identifier? (default: ' . $id . ')</question> ', $id);
     $secret = $this->ask('New client secret? (default: ' . $secret . ')</question> ', $secret);
     $name = $this->ask('New client name?</question> ');
     $trusted = $this->confirm('Is this client trusted? (y/N)</question> ', false);
     $redirectUris[] = ['uri' => $this->ask('Default client redirect URI?</question> '), 'default' => true];
     if (!$id or !$secret or !$name or empty($redirectUris)) {
         $this->blankLine();
         $this->error('One or more of the questions was not answered. Unable to make new client.');
         exit;
     }
     while ($this->confirm('Would you like to create another client redirect URI? (y/N)</question> ', false)) {
         $redirectUris[] = ['uri' => $this->ask('Client redirect URI?</question> '), 'default' => false];
     }
     $this->blankLine();
     $client = $this->storage('client')->create($id, $secret, $name, $redirectUris, $trusted);
     $this->info('Client created! JSON representation of new client:');
     $this->blankLine();
     $this->line(json_encode($client->getAttributes(), JSON_PRETTY_PRINT));
     $this->blankLine();
 }
コード例 #2
0
ファイル: Grant.php プロジェクト: nguyen-vq/oauth2-server
 /**
  * Generate a new token.
  * 
  * @return string
  */
 public function generateToken()
 {
     return Token::make();
 }