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 用verilog实现tanh函数和softplus函数
  • ¥15 Hadoop集群部署启动Hadoop时碰到问题
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 QTableWidget重绘程序崩溃
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站