1

我刚刚使用 Flex 开始了一个新的 Symfony 3.4 项目。我遵循了 FOSOAuthBundle 的官方文档,但是当我想创建一个令牌时,我遇到了/oauth/v2/token这个错误:“Unrecognized field: randomId”

这是我的配置文件:

#config/packages/fos_oauth_server.yaml
fos_oauth_server:
 db_driver: orm
 client_class:        App\Entity\Client
 access_token_class:  App\Entity\AccessToken
 refresh_token_class: App\Entity\RefreshToken
 auth_code_class:     App\Entity\AuthCode
 service:
  user_provider: fos_user.user_provider.username
  options:
   supported_scopes: user

#config/packages/security.yaml
security:
  providers:
   user_provider:
    id: fos_user.user_provider.username
  firewalls:
      oauth_token:
          pattern:    ^/oauth/v2/token
          security:   false

      oauth_authorize:
          pattern:    ^/oauth/v2/auth
          security:   false
          # Add your favorite authentication process here

      main:
          pattern:    ^/
          fos_oauth:  true
          stateless:  true
          anonymous:  false # can be omitted as its default value

  access_control:
      - { path: ^/, roles: [ IS_AUTHENTICATED_FULLY ] }

    #config/packages/doctrine.yaml
parameters:
    env(DATABASE_URL): ''

doctrine:
    dbal:
        # configure these for your database server
        driver: 'pdo_mysql'
        server_version: '5.7'
        charset: utf8mb4

        # With Symfony 3.3, remove the `resolve:` prefix
        url: '%env(resolve:DATABASE_URL)%'
    orm:
        auto_generate_proxy_classes: '%kernel.debug%'
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

你有想法吗?

4

0 回答 0