Skip to content

Commit e3c1c41

Browse files
authored
Merge pull request #90 from Kit/add-client-id-to-get-access-token-by-api-key
Add `client_id` to `accounts/oauth_access_token`
2 parents d71ecbb + 93f80cc commit e3c1c41

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/class-convertkit-api-v4.php

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ public function get_access_token_by_api_key_and_secret( $api_key, $api_secret )
492492
array(
493493
'api_key' => $api_key,
494494
'api_secret' => $api_secret,
495+
'client_id' => $this->client_id,
495496
)
496497
);
497498

tests/wpunit/APITest.php

+32
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,38 @@ public function testGetAccessTokenByInvalidAPIKeyAndSecret()
604604
$this->assertEquals('Authorization Failed: API Secret not valid', $result->get_error_message());
605605
}
606606

607+
/**
608+
* Test that fetching an Access Token using an invalid client ID returns a WP_Error.
609+
*
610+
* @since 2.0.7
611+
*/
612+
public function testGetAccessTokenByAPIKeyAndSecretWithInvalidClientID()
613+
{
614+
$api = new ConvertKit_API_V4( 'invalidClientID', $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'] );
615+
$result = $api->get_access_token_by_api_key_and_secret(
616+
$_ENV['CONVERTKIT_API_KEY'],
617+
$_ENV['CONVERTKIT_API_SECRET']
618+
);
619+
$this->assertInstanceOf(WP_Error::class, $result);
620+
$this->assertEquals($result->get_error_code(), $this->errorCode);
621+
}
622+
623+
/**
624+
* Test that fetching an Access Token using a blank client ID returns a WP_Error.
625+
*
626+
* @since 2.0.7
627+
*/
628+
public function testGetAccessTokenByAPIKeyAndSecretWithBlankClientID()
629+
{
630+
$api = new ConvertKit_API_V4( '', $_ENV['CONVERTKIT_OAUTH_REDIRECT_URI'] );
631+
$result = $api->get_access_token_by_api_key_and_secret(
632+
$_ENV['CONVERTKIT_API_KEY'],
633+
$_ENV['CONVERTKIT_API_SECRET']
634+
);
635+
$this->assertInstanceOf(WP_Error::class, $result);
636+
$this->assertEquals($result->get_error_code(), $this->errorCode);
637+
}
638+
607639
/**
608640
* Test that supplying valid API credentials to the API class returns the expected account information.
609641
*

0 commit comments

Comments
 (0)