I am trying build a rest api on Symfony3 and using a combination of FOSOAuthServerBundle , JMSerializer and FOSUserBundle. I have the configurations set up to the best of my knowledge i however cannot get the api to return a token.
it in fact always returns {"error":"invalid_request","error_description":"Invalid grant_type parameter or parameter missing"}
despite providing the grant_type key and value
so i did a bunch of digging and tried suggestions on this FOSOAuthServerBundle: Invalid grant_type parameter or parameter missing and also this FOSOAuthServerBundle + FOSRestBundle + CamelCase = Not authenticating i still could not get it to work. from my findings i probably need to to disable the body listener which converts underscored keys to camel in either FOSRestBundle or the JMSerializer Bundle i however have no clue on how to do either I would appreciate pointers in the right direction on how to resolve the issue
my config.yml foss section looks like this
# FOSRest Configuration
fos_rest:
body_listener: true
zone:
- { path: ^/api }
allowed_methods_listener: true
format_listener:
rules:
- { path: '^/api', priorities: ['json'], fallback_format: json, prefer_extension: false }
- { path: '^/', priorities: [ 'text/html', '*/*'], fallback_format: html, prefer_extension: true }
param_fetcher_listener: true
view:
view_response_listener: 'force'
formats:
json: true
security.yml look like this the
security: encoders: UserBundle\Entity\User: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_USER
ROLE_SUPER_ADMIN: ROLE_ADMIN
providers:
in_memory:
memory: ~
fos_userbundle:
id: fos_user.user_provider.username
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
authenticate
pattern: ^/
form_login:
provider: fos_userbundle
#csrf_provider: security.csrf.token_manager
logout: true
anonymous: true
#auth api stuff
oauth_token:
pattern: ^/oauth/v2/token
security: false
api_doc:
pattern: ^/api/doc
security: false
api:
pattern: ^/api
fos_oauth: true
stateless: true
#end
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/, role: ROLE_ADMIN }
#api
- { path: ^/api, roles: [ IS_AUTHENTICATED_FULLY ] }