private function createTokenServer()
    {
        // Catch errors for pdo object creation and creating the server
        try {
            // Create the server
            $storage = new \OAuth2\Storage\Pdo(
                [
                    'dsn' => $this->configuration->getDsn(),
                    'username' => $this->configuration->getUsername(),
                    'password' => $this->configuration->getPassword(),
                ]
            );
            $server = new \OAuth2\Server($storage);

            // Add grant types
            if ($this->configuration->getAuthorizationMode() === 1) {
                $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
            } elseif ($this->configuration->getAuthorizationMode() === 2) {
                $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
            } elseif ($this->configuration->getAuthorizationMode() === 3) {
                $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
                $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
            } else {
                throw new \Exception("Unknown authorization mode: \"{$this->configuration->getAuthorizationMode()}\".");
            }
        } catch (\Exception $ex) {
            throw $ex;
        }

        $this->tokenServer = $server;
        return $this;
    }
private function createTokenServer()
    {
        // Catch errors for pdo object creation and creating the server
        try {
            // Create the server
            $storage = new \OAuth2\Storage\Pdo(
                [
                    'dsn' => $this->configuration->getDsn(),
                    'username' => $this->configuration->getUsername(),
                    'password' => $this->configuration->getPassword(),
                ]
            );
            $server = new \OAuth2\Server($storage);

            // Add grant types
            if ($this->configuration->getAuthorizationMode() === 1) {
                $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
            } elseif ($this->configuration->getAuthorizationMode() === 2) {
                $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
            } elseif ($this->configuration->getAuthorizationMode() === 3) {
                $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
                $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
            } else {
                throw new \Exception("Unknown authorization mode: \"{$this->configuration->getAuthorizationMode()}\".");
            }
        } catch (\Exception $ex) {
            throw $ex;
        }

        $this->tokenServer = $server;
        return $this;
    }
private function createTokenServer ( ) { // Catch errors for pdo object creation and creating the server try { // Create the server $ storage = new \ OAuth2 \ Storage \ Pdo ( [ 'dsn' => $ this -> configuration -> getDsn ( ) , 'username' => $ this -> configuration -> getUsername ( ) , 'password' => $ this -> configuration -> getPassword ( ) , ] ) ; $ server = new \ OAuth2 \ Server ( $ storage ) ; // Add grant types if ( $ this -> configuration -> getAuthorizationMode ( ) === 1 ) { $ server -> addGrantType ( new \ OAuth2 \ GrantType \ ClientCredentials ( $ storage ) ) ; } elseif ( $ this -> configuration -> getAuthorizationMode ( ) === 2 ) { $ server -> addGrantType ( new \ OAuth2 \ GrantType \ AuthorizationCode ( $ storage ) ) ; } elseif ( $ this -> configuration -> getAuthorizationMode ( ) === 3 ) { $ server -> addGrantType ( new \ OAuth2 \ GrantType \ ClientCredentials ( $ storage ) ) ; $ server -> addGrantType ( new \ OAuth2 \ GrantType \ AuthorizationCode ( $ storage ) ) ; } else { throw new \ Exception ( "Unknown authorization mode: \"{$this->configuration->getAuthorizationMode()}\"." ) ; } } catch ( \ Exception $ ex ) { throw $ ex ; } $ this -> tokenServer = $ server ; return $ this ; }
Creates the new token server.
Sets the connection to the database and grant types.

@throws @see OAuth2 package.

@return self The current object.
Creates the new token server . Sets the connection to the database and grant types .