FOSOAuthServerBundle令牌身份验证失败

时间:2014-05-15 22:36:48

标签: symfony oauth fosuserbundle fosrestbundle fosoauthserverbundle

我正在使用Symfony2开发一个网站,其中包含一个用于从移动应用程序访问数据的API。我使用FOSUserBundle在网站上进行身份验证,FOSRestBundle& API的FOSOAuthServerBundle。 我在http://blog.tankist.de/blog/2013/07/17/oauth2-explained-part-2-setting-up-oauth2-with-symfony2-using-fosoauthserverbundle/上学习了教程以实现捆绑。 我使用密码作为grant_type,因此我可以使用用户的登录/密码组合登录API。我成功地从捆绑包中获取了access_token,但是当我尝试使用此令牌访问api时(例如/api/user?access_token=MY_TOKEN),我总是被重定向到我的网站主页(这是我的登录页面)。我真的不知道我错过了什么。 这是我的配置:

#app/Resources/config.yml
fos_oauth_server:
db_driver: orm
client_class: Cubbyhole\ApiBundle\Entity\Client
access_token_class: Cubbyhole\ApiBundle\Entity\AccessToken
refresh_token_class: Cubbyhole\ApiBundle\Entity\RefreshToken
auth_code_class: Cubbyhole\ApiBundle\Entity\AuthCode
service:
    user_provider: fos_user.user_manager

#app/Resources/security.yml
#Firewalls for OAuth2
    oauth_token:
        pattern: ^/oauth/v2/token
        security: false
    oauth_authorize:
        pattern: ^/oauth/v2/auth
        form_login:
            provider: fos_userbundle
            check_path: fos_user_security_check
            login_path: fos_user_security_login
        anonymous: true
    api:
        pattern: ^/api
        fos_oauth: true
        stateless: true

access_control:
- { path: ^/api/oauth/v2, roles: [ IS_AUTHENTICATED_FULLY, IS_AUTHENTICATED_ANONYMOUSLY ] }
- { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] }

0 个答案:

没有答案
相关问题