knpuniversity / oauth2-client-bundle

Easily talk to an OAuth2 server for social functionality in Symfony
https://symfonycasts.com
MIT License
786 stars 146 forks source link

There is no extension able to load the configuration for "knpu_oauth2_client" #195

Closed flesage-000 closed 5 years ago

flesage-000 commented 5 years ago

Hello,

I'trying to use oauth2-client-bundle for a project but i'm stuck at STEP 3 and got this error :

There is no extension able to load the configuration for "knpu_oauth2_client"

Here is my script (but similar to HP tutorial)

FacebookController.php `<?php namespace App\Controller;

use KnpU\OAuth2ClientBundle\Client\ClientRegistry; use League\OAuth2\Client\Provider\Exception\IdentityProviderException; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Annotation\Route;

class FacebookController extends Controller { /**

knpu_oauth2_client.yaml `knpu_oauth2_client: clients:

will create service: "knpu.oauth2.client.discord"

    # an instance of: KnpU\OAuth2ClientBundle\Client\Provider\DiscordClient
    # composer require wohali/oauth2-discord-new
    discord_main:
        # must be "discord" - it activates that type!
        type: discord
        # add and configure client_id and client_secret in parameters.yml
        client_id: '%env(OAUTH_DISCORD_CLIENT_ID)%'
        client_secret: '%env(OAUTH_DISCORD_CLIENT_SECRET)%'
        # a route name you'll create
        redirect_route: connect_discord_check
        redirect_params: {}

        # whether to check OAuth2 "state": defaults to true
        # use_state: true
  # the key "facebook_main" can be anything, it
  # will create a service: "knpu.oauth2.client.facebook_main"
    facebook_main:
        # this will be one of the supported types
        type: facebook
        client_id: '%env(OAUTH_FACEBOOK_ID)%'
        client_secret: '%env(OAUTH_FACEBOOK_SECRET)%'
        # the route that you're redirected to after
        # see the controller example below
        redirect_route: connect_facebook_check
        redirect_params: {}
        graph_api_version: v2.12`

- Initialy i use this to a OAuth2 Discord, so i duplicate for discord during the tutorial, but i have the same error for both - env var are set in .env file

I'm new to Symfony framework, so i assume that question is probably stupid :D.

MolloKhan commented 5 years ago

Hey @flesage-000 what the error means

There is no extension able to load the configuration for "knpu_oauth2_client"

Is that Symfony is reading your knpu_oauth2_client.yaml file but nothing could process it. I believe this is happening because the bundle is not activated. Double check your config/bundles.php file. You are on Symfony4, right?

flesage-000 commented 5 years ago

Hey @larzuk91

Indeed i'm on Symfony 4.

I read something about that but i thought it was automatic for this version of Symfony !

I'll search on the web how to activate manually a bundle, thx !

MolloKhan commented 5 years ago

Indeed i'm on Symfony 4.

Hmm, in that case, it should be enabled automatically. Look for the bundle inside config/bundles.php If it's not for any reason, then just add it there and try again

flesage-000 commented 5 years ago

Here is the bundles.php

return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle::class => ['all' => true], Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true], Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\WebServerBundle\WebServerBundle::class => ['dev' => true], ];

and version is

const VERSION = '4.3.4';

downloaded/installed 3 days ago.

flesage-000 commented 5 years ago

Well... @larzuk91

Now it's works, it seems that i don't understand an install question

The recipe for this package comes from the "contrib" repository, which is open to community contributions. Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/knpuniversity/oauth2-client-bundle/1.20

I thought by say "n" it install another version....

BTW, i can now see the discord login :D. Thanks a lot :)

MolloKhan commented 5 years ago

Ah, yes, by default composer asks you if you want to install recipes coming from the contrib repository. It's just for security reasons, there could be a bad/hacky recipe.

I'm glad to know that you could fix your problem. I'm closing this issue but if you have more problems feel free to open another one