Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client_id to accounts/oauth_access_token #90

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/class-convertkit-api-v4.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
);

Expand Down
32 changes: 32 additions & 0 deletions tests/wpunit/APITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
Loading