AxeWP / wp-graphql-headless-login

A WordPress plugin that provides Headless login and authentication for WPGraphQL, supporting traditional passwords, OAuth2/OpenID Connect, JWT, and more.
GNU General Public License v3.0
66 stars 11 forks source link

Generic Oauth2 can not be enabled #56

Closed ryntab closed 1 year ago

ryntab commented 1 year ago

Description

Hello! I am trying to set up Discord Oauth2 with the generic Oauth2 provider. However I get the error message "debugMessage": "Provider generic-oauth2 is not enabled."

I can see in my database that the isEnabled property is correct for the provider, and based on what i'm seeing in the ProviderRegistry.php file I would be receiving another message if there was error in the config.

Steps to reproduce

Run a generic Oauth2 login mutation

mutation discordAuth($code: String = "xxx") {
  login(
    input: {provider: GENERIC_OAUTH2, oauthResponse: {code: $code, state: ""}}
  ) {
    authToken
  }
}

Additional context

No response

Plugin Version

0.0.7

WordPress Version

Version 6.2

WPGraphQL Version

1.14.0

Additional enviornmental details

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have disabled ALL plugins except for WPGraphQL and Headless Login for WPGraphQL

stephane-segning commented 1 year ago

So I did some investigations and I have an Idea where the error might be coming from.

Inside of the class Generic.php, we have this:

public static function get_slug() : string {
    return 'generic-oauth2';
}

but in the class ProviderRegistry.php, it's

$registered_providers = apply_filters(
    'graphql_login_registered_provider_configs',
    [
      'facebook' => Facebook::class,
--->  'generic' => Generic::class, <---
      'github' => GitHub::class,
      'google' => Google::class,
      'instagram' => Instagram::class,
      'linkedin' => LinkedIn::class,
      'password' => Password::class,
      'siteToken' => SiteToken::class,
    ]
);

This is a first check. I suppose the slug should be the same for the overall to work.

Edit:

I just proceed to the changes on my installation and it worked till the end.

justlevine commented 1 year ago

I have confirmed the issue and am hoping to get a fix out shortly. @stephane-segning great catch, I need to straighten out the use of slugs/keys/types in a few places.

Ps: @ryntab this issue qualifies for my WPGraphQL Spring Cleaning campaign, where I'm donating dev hours to WPGraphQL projects for every issue/PR opened between now and April 31st. If you're interested, let me know via the link where you want the time donated to.

justlevine commented 1 year ago

And released: https://github.com/AxeWP/wp-graphql-headless-login/releases/tag/0.0.8