diff -u b/src/AuthenticationPluginInterface.php b/src/AuthenticationPluginInterface.php --- b/src/AuthenticationPluginInterface.php +++ b/src/AuthenticationPluginInterface.php @@ -18,6 +18,8 @@ * @return array * Options (such as Authentication headers) to be added to the request. + * + * @link http://docs.guzzlephp.org/en/latest/request-options.html */ - public function authenticate(); + public function getAuthenticationOptions(); } diff -u b/src/Plugin/migrate_plus/authentication/Basic.php b/src/Plugin/migrate_plus/authentication/Basic.php --- b/src/Plugin/migrate_plus/authentication/Basic.php +++ b/src/Plugin/migrate_plus/authentication/Basic.php @@ -18,7 +18,7 @@ /** * {@inheritdoc} */ - public function authenticate() { + public function getAuthenticationOptions() { return [ 'auth' => [ $this->configuration['username'], diff -u b/src/Plugin/migrate_plus/authentication/Digest.php b/src/Plugin/migrate_plus/authentication/Digest.php --- b/src/Plugin/migrate_plus/authentication/Digest.php +++ b/src/Plugin/migrate_plus/authentication/Digest.php @@ -18,7 +18,7 @@ /** * {@inheritdoc} */ - public function authenticate() { + public function getAuthenticationOptions() { return [ 'auth' => [ $this->configuration['username'], diff -u b/src/Plugin/migrate_plus/authentication/OAuth2.php b/src/Plugin/migrate_plus/authentication/OAuth2.php --- b/src/Plugin/migrate_plus/authentication/OAuth2.php +++ b/src/Plugin/migrate_plus/authentication/OAuth2.php @@ -3,10 +3,10 @@ namespace Drupal\migrate_plus\Plugin\migrate_plus\authentication; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateException; use Drupal\migrate_plus\AuthenticationPluginBase; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; -use Sainsburys\Guzzle\Oauth2\AccessToken; use Sainsburys\Guzzle\Oauth2\GrantType\AuthorizationCode; use Sainsburys\Guzzle\Oauth2\GrantType\ClientCredentials; use Sainsburys\Guzzle\Oauth2\GrantType\JwtBearer; @@ -16,6 +16,8 @@ /** * Provides OAuth2 authentication for the HTTP resource. + * + * @link https://packagist.org/packages/sainsburys/guzzle-oauth2-plugin * * @Authentication( * id = "oauth2", @@ -27,7 +29,7 @@ /** * {@inheritdoc} */ - public function authenticate() { + public function getAuthenticationOptions() { $handlerStack = HandlerStack::create(); $client = new Client([ 'handler'=> $handlerStack, @@ -51,6 +53,9 @@ case 'refresh_token': $grant_type = new RefreshToken($client, $this->configuration); break; + default: + throw new MigrateException("Unrecognized grant_type {$this->configuration['grant_type']}."); + break; } $middleware = new OAuthMiddleware($client, $grant_type); diff -u b/src/Plugin/migrate_plus/data_fetcher/Http.php b/src/Plugin/migrate_plus/data_fetcher/Http.php --- b/src/Plugin/migrate_plus/data_fetcher/Http.php +++ b/src/Plugin/migrate_plus/data_fetcher/Http.php @@ -80,7 +80,7 @@ try { $options = ['headers' => $this->getRequestHeaders()]; if (!empty($this->configuration['authentication'])) { - $options = array_merge($options, $this->getAuthenticationPlugin()->authenticate()); + $options = array_merge($options, $this->getAuthenticationPlugin()->getAuthenticationOptions()); } $response = $this->httpClient->get($url, $options); if (empty($response)) {