OAuthStorage::__construct() 必须实现接口 UserProviderInterface,给定的 UserManager 实例
OAuthStorage::__construct() must implement interface UserProviderInterface, instance of UserManager given
我正在使用 OAuth 授权进行简单的休息 API。
我按照以下教程设置了所有内容(我从全新安装的 symfony 3 应用程序开始)
https://gist.github.com/tjamps/11d617a4b318d65ca583
安装完所有内容后,我按以下方式更改了 config.yml
fos_oauth_server:
db_driver: orm
client_class: UserBundle\Entity\Client
access_token_class: UserBundle\Entity\AccessToken
refresh_token_class: UserBundle\Entity\RefreshToken
auth_code_class: UserBundle\Entity\AuthCode
service:
user_provider: fos_user.user_provider.username_email
我还更改了 security.yml 以允许登录时使用用户名和电子邮件
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
# http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
oauth_token: # Everyone can access the access token URL.
pattern: ^/oauth/v2/token
security: false
api:
pattern: ^/ # All URLs are protected
fos_oauth: true # OAuth2 protected resource
stateless: true # Do no set session cookies
anonymous: false # Anonymous access is not allowed
现在我得到以下错误:
Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Catchable Fatal Error: Argument 5 passed to FOS\OAuthServerBundle\Storage\OAuthStorage::__construct() must implement interface Symfony\Component\Security\Core\User\UserProviderInterface, instance of FOS\UserBundle\Doctrine\UserManager given, called in /Users/%username/rai-api/var/cache/prod/appProdProjectContainer.php on line 1614 and defined' in /Users/%username/rai-api/vendor/friendsofsymfony/oauth-server-bundle/Storage/OAuthStorage.php on line 80
我正在使用 symfony 3.2
首先,只要看到这一行就进行更改
var/cache/prod/appProdProjectContainer.php
始终考虑删除 var/cache/prod 文件夹并根据您的缓存设置 and/or 您更改了哪些文件,重新启动 apache。
或者,只需使用开发环境,因为它旨在让您的开发生活更轻松,尽管速度要慢得多。
我正在使用 OAuth 授权进行简单的休息 API。
我按照以下教程设置了所有内容(我从全新安装的 symfony 3 应用程序开始)
https://gist.github.com/tjamps/11d617a4b318d65ca583
安装完所有内容后,我按以下方式更改了 config.yml
fos_oauth_server:
db_driver: orm
client_class: UserBundle\Entity\Client
access_token_class: UserBundle\Entity\AccessToken
refresh_token_class: UserBundle\Entity\RefreshToken
auth_code_class: UserBundle\Entity\AuthCode
service:
user_provider: fos_user.user_provider.username_email
我还更改了 security.yml 以允许登录时使用用户名和电子邮件
security:
encoders:
FOS\UserBundle\Model\UserInterface: sha512
# http://symfony.com/doc/current/security.html#b-configuring-how-users-are-loaded
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username_email
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
oauth_token: # Everyone can access the access token URL.
pattern: ^/oauth/v2/token
security: false
api:
pattern: ^/ # All URLs are protected
fos_oauth: true # OAuth2 protected resource
stateless: true # Do no set session cookies
anonymous: false # Anonymous access is not allowed
现在我得到以下错误:
Fatal error: Uncaught exception 'Symfony\Component\Debug\Exception\ContextErrorException' with message 'Catchable Fatal Error: Argument 5 passed to FOS\OAuthServerBundle\Storage\OAuthStorage::__construct() must implement interface Symfony\Component\Security\Core\User\UserProviderInterface, instance of FOS\UserBundle\Doctrine\UserManager given, called in /Users/%username/rai-api/var/cache/prod/appProdProjectContainer.php on line 1614 and defined' in /Users/%username/rai-api/vendor/friendsofsymfony/oauth-server-bundle/Storage/OAuthStorage.php on line 80
我正在使用 symfony 3.2
首先,只要看到这一行就进行更改
var/cache/prod/appProdProjectContainer.php
始终考虑删除 var/cache/prod 文件夹并根据您的缓存设置 and/or 您更改了哪些文件,重新启动 apache。
或者,只需使用开发环境,因为它旨在让您的开发生活更轻松,尽管速度要慢得多。