concrete/controllers/single_page/dashboard/system/api/integrations.php
public function create()
    {
        $this->add();
        $this->validateIntegrationRequest();
        if (!$this->token->validate('create')) {
            $this->error->add($this->token->getErrorMessage());
        }

        if ($this->error->has()) {
            return;
        }

        $factory = $this->app->make(ClientFactory::class);
        $credentials = $factory->generateCredentials();

        // Create a new client while hashing the new secret
        $client = $factory->createClient(
            $this->request->request->get('name'),
            $this->request->request->get('redirect'),
            [],
            $credentials->getKey(),
            password_hash($credentials->getSecret(), PASSWORD_DEFAULT)
        );

        // Persist the new client to the database
        $this->entityManager->persist($client);
        $this->entityManager->flush();
        $this->flash('success', t('Integration saved successfully.'));
        $this->flash('clientSecret', $credentials->getSecret());

        return $this->redirect('/dashboard/system/api/integrations/', 'view_client', $client->getIdentifier());
    }
public function create()
    {
        $this->add();
        $this->validateIntegrationRequest();
        if (!$this->token->validate('create')) {
            $this->error->add($this->token->getErrorMessage());
        }

        if ($this->error->has()) {
            return;
        }

        $factory = $this->app->make(ClientFactory::class);
        $credentials = $factory->generateCredentials();

        // Create a new client while hashing the new secret
        $client = $factory->createClient(
            $this->request->request->get('name'),
            $this->request->request->get('redirect'),
            [],
            $credentials->getKey(),
            password_hash($credentials->getSecret(), PASSWORD_DEFAULT)
        );

        // Persist the new client to the database
        $this->entityManager->persist($client);
        $this->entityManager->flush();
        $this->flash('success', t('Integration saved successfully.'));
        $this->flash('clientSecret', $credentials->getSecret());

        return $this->redirect('/dashboard/system/api/integrations/', 'view_client', $client->getIdentifier());
    }
public function create ( ) { $ this -> add ( ) ; $ this -> validateIntegrationRequest ( ) ; if ( ! $ this -> token -> validate ( 'create' ) ) { $ this -> error -> add ( $ this -> token -> getErrorMessage ( ) ) ; } if ( $ this -> error -> has ( ) ) { return ; } $ factory = $ this -> app -> make ( ClientFactory :: class ) ; $ credentials = $ factory -> generateCredentials ( ) ; // Create a new client while hashing the new secret $ client = $ factory -> createClient ( $ this -> request -> request -> get ( 'name' ) , $ this -> request -> request -> get ( 'redirect' ) , [ ] , $ credentials -> getKey ( ) , password_hash ( $ credentials -> getSecret ( ) , PASSWORD_DEFAULT ) ) ; // Persist the new client to the database $ this -> entityManager -> persist ( $ client ) ; $ this -> entityManager -> flush ( ) ; $ this -> flash ( 'success' , t ( 'Integration saved successfully.' ) ) ; $ this -> flash ( 'clientSecret' , $ credentials -> getSecret ( ) ) ; return $ this -> redirect ( '/dashboard/system/api/integrations/' , 'view_client' , $ client -> getIdentifier ( ) ) ; }
Request handler to create new client objects

This method:
1. Makes sure a name exists
2. Validates the request token `create`
3. Returns if any errors exist
4. Uses a ClientFactory to create a new client object
5. Uses password_hash on the client secret before storing to the database
6. Stores the secret to a session flash bag
7. Redirects to the view_client action
Request handler to create new client objects