oauth2-server-php
oauth2-server-php copied to clipboard
Error: You must supply a storage object implementing \OAuth2\Storage\ClientInterface to use the authorize server
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
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