2

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

谁能帮忙,我错过了什么?

谢谢!

4

1 回答 1

1

不要忘记执行第 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

于 2014-05-02T11:12:13.830 回答