diff --git a/src/class-convertkit-api-v4.php b/src/class-convertkit-api-v4.php index cfde53e..3b72f5b 100644 --- a/src/class-convertkit-api-v4.php +++ b/src/class-convertkit-api-v4.php @@ -492,6 +492,7 @@ public function get_access_token_by_api_key_and_secret( $api_key, $api_secret ) array( 'api_key' => $api_key, 'api_secret' => $api_secret, + 'client_id' => $this->client_id, ) ); diff --git a/tests/wpunit/APITest.php b/tests/wpunit/APITest.php index f1af417..f1dadf0 100644 --- a/tests/wpunit/APITest.php +++ b/tests/wpunit/APITest.php @@ -604,6 +604,38 @@ public function testGetAccessTokenByInvalidAPIKeyAndSecret() $this->assertEquals('Authorization Failed: API Secret not valid', $result->get_error_message()); } + /** + * Test that fetching an Access Token using an invalid client ID returns a WP_Error. + * + * @since 2.0.7 + */ + public function testGetAccessTokenByAPIKeyAndSecretWithInvalidClientID() + { + $api = new ConvertKit_API_V4( 'invalidClientID', $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'] ); + $result = $api->get_access_token_by_api_key_and_secret( + $_ENV['CONVERTKIT_API_KEY'], + $_ENV['CONVERTKIT_API_SECRET'] + ); + $this->assertInstanceOf(WP_Error::class, $result); + $this->assertEquals($result->get_error_code(), $this->errorCode); + } + + /** + * Test that fetching an Access Token using a blank client ID returns a WP_Error. + * + * @since 2.0.7 + */ + public function testGetAccessTokenByAPIKeyAndSecretWithBlankClientID() + { + $api = new ConvertKit_API_V4( '', $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'] ); + $result = $api->get_access_token_by_api_key_and_secret( + $_ENV['CONVERTKIT_API_KEY'], + $_ENV['CONVERTKIT_API_SECRET'] + ); + $this->assertInstanceOf(WP_Error::class, $result); + $this->assertEquals($result->get_error_code(), $this->errorCode); + } + /** * Test that supplying valid API credentials to the API class returns the expected account information. *