2

I'm working on a REST API in Symfony2 (created with FosRestBundle).

Before oauth was enabled I could try the API methods in the sandbox provided by nelmio.

Example:

GET /api/products/{id}.json

However now that oauth is enabled in order to call an API method I have to add the oauth token as a query string.

Example:

GET /api/products/{id}.json?access_token=ZWRhNTE2MGUzZWE4ZTIzNDIxMGUxNjZkY2Yx...

These api calls work outside nelmio without any problems.

In order to activate support for oauth in nelmio I've added the following config in /app/config.yml:

nelmio_api_doc: 
    sandbox:
        authentication:            
            name: access_token      
            delivery: http
            type:     bearer

After that it asks for an api key at the top of the screen, however if I set there the oauth token I still get an unauthorized response when trying to use the sandbox.

Any idea how to fix this?

cezar
  • 11,616
  • 6
  • 48
  • 84
rfc1484
  • 9,441
  • 16
  • 72
  • 123

1 Answers1

3

I also have a FOSRestBundle based API. I am not sure you need to force a name in the authentication block.

This config worked for me:

nelmio_api_doc:
    name: My awesome service
    sandbox:
        authentication:
            delivery: http
            type:     bearer
Jocelyn
  • 277
  • 4
  • 21