OAuthStorage :: __ construct()必须实现接口UserProviderInterface,UserManager的实例给出

时间:2017-02-04 17:21:57

标签: php symfony fosuserbundle fosrestbundle fosoauthserverbundle

我正在使用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,i nstance of FOS \ UserBundle \ Doctrine \ UserManager,在 /中调用用户/%用户名/ rai-api / var / cache / prod / appProdProjectContainer.php 在1614行并定义为'in / Users /%username / rai-api / vendor / friendsofsymfony / oauth-server-第80行的bundle / Storage / OAuthStorage.php

我正在使用symfony 3.2

1 个答案:

答案 0 :(得分:1)

首先,在看到此行时进行更改

var/cache/prod/appProdProjectContainer.php

始终考虑删除var / cache / prod文件夹,并根据您的缓存设置和/或更改的文件,重新启动apache。

或者,只需使用开发环境,因为它的目的是让你的开发生活更轻松,但速度要慢得多。

相关问题