FriendsOfSymfony / FOSOAuthServerBundle

A server side OAuth2 Bundle for Symfony
1.09k stars 451 forks source link

Could not load type "fos_oauth_server_authorize" #386

Open psampaz opened 8 years ago

psampaz commented 8 years ago

While trying to access fos_oauth_server_authorize (oauth/v2/auth) route

I get the following error:

Could not load type "fos_oauth_server_authorize"

This is my config

# app/config/config.yml

fos_oauth_server:
    db_driver: orm       # Driver availables: orm, mongodb, or propel
    client_class:        OAuth2ServerBundle\Entity\Client
    access_token_class:  OAuth2ServerBundle\Entity\AccessToken
    refresh_token_class: OAuth2ServerBundle\Entity\RefreshToken
    auth_code_class:     OAuth2ServerBundle\Entity\AuthCode

This is the output from "php bin/console debug:config fos_oauth_server"

Current configuration for extension with alias "fos_oauth_server"
=================================================================

fos_oauth_server:
    db_driver: orm
    client_class: OAuth2ServerBundle\Entity\Client
    access_token_class: OAuth2ServerBundle\Entity\AccessToken
    refresh_token_class: OAuth2ServerBundle\Entity\RefreshToken
    auth_code_class: OAuth2ServerBundle\Entity\AuthCode
    model_manager_name: null
    authorize:
        form: { type: fos_oauth_server_authorize, handler: fos_oauth_server.authorize.form.handler.default, name: fos_oauth_server_authorize_form, validation_groups: [Authorize, Default] }
    service:
        storage: fos_oauth_server.storage.default
        user_provider: null
        client_manager: fos_oauth_server.client_manager.default
        access_token_manager: fos_oauth_server.access_token_manager.default
        refresh_token_manager: fos_oauth_server.refresh_token_manager.default
        auth_code_manager: fos_oauth_server.auth_code_manager.default
        options: {  }
    template:
        engine: twig

Any ideas what could go wrong?

phoenixgao commented 8 years ago

You are using symfony 3?

I think atm this bundle is far from compatible with sf3, I fixed these form errors but there are more things incompatible.

ghost commented 8 years ago

Yes I use Symfony 3 with FOSOAuthServerBundle 1.5.0

phoenixgao commented 8 years ago

The Form factory doesn't support nasty type argument anymore, to fix your error, you can define a parameter to override the authorize form type:

# dirty fixes:
parameters:
    fos_oauth_server.authorize.form.type: YourBundle\Form\Type\AuthorizeFormType

Copy the AuthorizeFormType.php from fos oauth server bundle to your bundle and change all the 'hidden' in builder to "HiddenType::class" (don't forget add use statement)

But then you will find you can't get client_id from request because this:

https://github.com/symfony/symfony/blob/2.8/src%2FSymfony%2FComponent%2FHttpFoundation%2FRequest.php#L728

And they are still use it here

https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/blob/master/Controller%2FAuthorizeController.php#L155

is removed from sf3.

I'll create a fork to fix..... but hmmm home time.

Or you can try to implement your own controller.

psampaz commented 8 years ago

Thanks for the fast reply.

Do you suggest not to use this bundle with sf3 on production?

GuilhemN commented 8 years ago

If you can wait i'll fix them next week but I'm not near a computer for now...

Spomky commented 8 years ago

Hi @Ener-Getick ,

Take a look at the LegacyFormHelper on FosUserBundle. I fixed this problem on my projects using the same helper. Really smart.

GuilhemN commented 8 years ago

Yeah @Spomky I already used it too, that's a really smart fix :-) I just won't be near a computer this week so I can merge a PR but I can't create it myself.

snjypl commented 8 years ago

I have tried a fix for this issue in my pull request. https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/pull/383