FOSOAuthServerBundle和FOSUserbundle

时间:2014-05-01 21:58:59

标签: security symfony fosuserbundle fosoauthserverbundle

我尝试使用FOSUserBundle和FOSOAuthServerBundle来保护我的symfony2应用程序。 我按照文档,创建了一个客户端等等。 但是当我调用/ oauth / v2 / auth时,我得到一个Route not found错误: 找不到“GET / oauth / v2 / auth_login”

的路线

任何人都可以帮助,我错过了什么?

谢谢!

1 个答案:

答案 0 :(得分:1)

不要忘记执行step 5并将路由添加到config.yml文件中:

# app/config/routing.yml
fos_oauth_server_token:
    resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml"

fos_oauth_server_authorize:
    resource: "@FOSOAuthServerBundle/Resources/config/routing/authorize.xml"

通过访问/ oauth / v2 / auth_login,你应该得到:

{"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}

这是因为您需要发送一些参数。如果您使用的是授权类型password,这是一个示例。您必须为您的网址提供以下参数:

  1. your_client_id
  2. your_client_secret
  3. a_user_username
  4. a_user_password

    http://yourWebsite.com/app_dev.php/oauth/v2/token?client_id=your_client_id&client_secret=your_client_secret&grant_type=password&username=a_user_username&password=a_user_password