Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Justaspa opened this issue May 15, 2022 · 1 comment

Comments

@Justaspa
Copy link

Justaspa commented May 15, 2022

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

@JoSSte
Copy link

JoSSte commented May 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants