AxeWP/wp-graphql-headless-login

External provider integration

pat-flew opened this issue · 1 comments

Description

Trying to integrate an external provider (TheNetworg\OAuth2\Client\Provider\Azure), I receive the error "The provider class must extend AbstractProvider".

It appears to be because OAuth2Config is expecting AbstractProvider to be in the WPGraphQL\Login\Vendor\League\OAuth2\Client\Provider namespace, rather than \League\OAuth2\Client\Provider, since it's been prefixed with Strauss.

I did not get the same error when testing the example here, but it's a bit beyond my ken at the moment to say why that's different (perhaps since it's already a dependency?)

I guess #96 (comment) is a similar report.

Steps to reproduce

Implement skeleton config like

<?php

namespace App\GraphQL\OAuthProviderConfig;

use TheNetworg\OAuth2\Client\Provider\Azure;

class AzureProviderConfig extends
	\WPGraphQL\Login\Auth\ProviderConfig\OAuth2\OAuth2Config
{
	public function __construct()
	{
		parent::__construct(Azure::class);
	}

	public static function get_name(): string
	{
		return __('Azure', 'wp-graphql-login');
	}

	public static function get_slug(): string
	{
		return 'azure';
	}

	protected static function client_options_schema(): array
	{
		return [];
	}

	public static function client_options_fields(): array
	{
		return [];
	}

	public function get_user_data(array $owner_details): array
	{
		return [];
	}

	protected function get_options(array $settings): array
	{
		return [];
	}
}
add_filter('graphql_login_registered_provider_configs', function (
	array $provider_configs
) {
	// Give the provider a unique slug, and pass the ProviderConfig class name.
	$provider_configs['azure'] =
		\App\GraphQL\OAuthProviderConfig\AzureProviderConfig::class;

	return $provider_configs;
});

Additional context

No response

Plugin Version

0.1.4

WordPress Version

6.4.2

WPGraphQL Version

1.19.0

Additional enviornmental details

No response

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

  • Yes

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

  • Yes
  • My issue is with a specific 3rd-party plugin.

Thanks for reporting this, @pat-flew (and for flagging that previous comment I missed).

This indeed seems to be related to Strauss and the type aliasing, will take a deeper look as soon as I get a moment.