oauth2-server-php icon indicating copy to clipboard operation
oauth2-server-php copied to clipboard

Error: You must supply a storage object implementing \OAuth2\Storage\ClientInterface to use the authorize server

Open Justaspa opened this issue 2 years ago • 1 comments

Hi, I created authorize server but am getting this error: You must supply a storage object implementing \OAuth2\Storage\ClientInterface to use the authorize server. How to submit a storage object to this server file? Are there any configurations? I would be very grateful for the help!

My Service file: namespace App\MyBundle\Service\OAuth;

use OAuth2\Server as OAuthServer;

class Server extends OAuthServer {

protected function createDefaultAuthorizeController()
{
    if (!isset($this->storages['client'])) {
        throw new \LogicException('You must supply a storage object implementing \OAuth2\Storage\ClientInterface to use the authorize server');
    }
    ...

} }

I'm useing this package for symfony 5.3

Justaspa avatar May 15 '22 15:05 Justaspa

have you read https://bshaffer.github.io/oauth2-server-php-docs/storage/custom/

If you are using mysql/mariadb you can basically ewxtend OAuth2\Storage\Pdo or write your own...

the OAuth2\Storage\Pdo implementation extends ClientCredentialsInterface which implements \OAuth2\Storage\ClientInterface

also if you read https://bshaffer.github.io/oauth2-server-php-docs/ the demo service implementation is

$storage = new OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $username, 'password' => $password));
$server = new OAuth2\Server($storage);
$server->addGrantType(new OAuth2\GrantType\AuthorizationCode($storage)); // or any grant type you like!
$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();

which again initiates a \OAuth2\Storage\Pdo

JoSSte avatar May 19 '22 14:05 JoSSte