我正在使用OAuth授权处理一个简单的rest 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
现在我收到以下错误:
致命错误:未捕获异常'Symfony \ Component \ Debug \ Exception \ ContextErrorException',消息'Catchable Fatal Error:Argument 5传递给FOS \ OAuthServerBundle \ Storage \ OAuthStorage :: __ construct()必须实现接口Symfony \ Component \ Security \ Core \ User \ UserProviderInterface,给出了FOS \ UserBundle \ Doctrine \ UserManager的实例,在第1614行的/Users/%username/rai-api/var/cache/prod/appProdProjectContainer.php中调用,并在/ Users /%username /中定义第80行的rai-api / vendor / friendsofsymfony / oauth-server-bundle / Storage / OAuthStorage.php
我正在使用symfony 3.2
1 回答
首先,在看到此行时进行更改
始终考虑删除var / cache / prod文件夹,并根据您的缓存设置和/或更改的文件,重新启动apache .
或者,只需使用开发环境,因为它的目的是让您的开发生活更轻松,尽管速度要慢得多 .