dounangqie4819 2017-02-04 17:21
浏览 71
已采纳

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

I am working on a simple rest API with OAuth authorization.

I followed the following tutorial to setup everything (I started with a clean installed symfony 3 application)

https://gist.github.com/tjamps/11d617a4b318d65ca583

After installing everything I changed the config.yml in the following way

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

I also the changed the security.yml to allow username and email on login

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

Now I get the following error:

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

I am using symfony 3.2

  • 写回答

1条回答 默认 最新

  • donglu2523 2017-02-04 22:06
    关注

    First, after making changes whenever you see this line

    var/cache/prod/appProdProjectContainer.php
    

    Always consider deleting the var/cache/prod folder and depending on you caching setup and/or what files you changed, restarting apache.

    Alternatively, just use the dev environment as it was meant to make your dev life easier although much slower.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?